show.blade.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. @extends('seller.layouts.app')
  2. @section('panel_content')
  3. <div class="aiz-titlebar mt-2 mb-4">
  4. <div class="h6">
  5. <span>{{ translate('Conversations With ')}}</span>
  6. @if ($conversation->sender_id == Auth::user()->id && $conversation->receiver->shop != null)
  7. <a href="{{ route('shop.visit', $conversation->receiver->shop->slug) }}" class="">{{ $conversation->receiver->shop->name }}</a>
  8. @endif
  9. </div>
  10. </div>
  11. <div class="card">
  12. <div class="card-header">
  13. <h5 class="card-title fs-16 fw-600 mb-0">#{{ $conversation->title }}
  14. (
  15. {{ translate('Between you and') }}
  16. @if ($conversation->sender_id == Auth::user()->id)
  17. {{ $conversation->receiver->name }}
  18. @else
  19. {{ $conversation->sender->name }}
  20. @endif
  21. )
  22. </h5>
  23. </div>
  24. <div class="card-body">
  25. <ul class="list-group list-group-flush">
  26. @foreach($conversation->messages as $message)
  27. <li class="list-group-item px-0">
  28. <div class="media mb-2">
  29. <img class="avatar avatar-xs mr-3" @if($message->user != null) src="{{ uploaded_asset($message->user->avatar_original) }}" @endif onerror="this.onerror=null;this.src='{{ static_asset('assets/img/avatar-place.png') }}';">
  30. <div class="media-body">
  31. <h6 class="mb-0 fw-600">
  32. @if ($message->user != null)
  33. {{ $message->user->name }}
  34. @endif
  35. </h6>
  36. <p class="opacity-50">{{$message->created_at}}</p>
  37. </div>
  38. </div>
  39. <p>
  40. {{ $message->message }}
  41. </p>
  42. </li>
  43. @endforeach
  44. </ul>
  45. <form class="pt-4" action="{{ route('seller.conversations.message_store') }}" method="POST">
  46. @csrf
  47. <input type="hidden" name="conversation_id" value="{{ $conversation->id }}">
  48. <div class="form-group">
  49. <textarea class="form-control" rows="4" name="message" placeholder="{{ translate('Type your reply') }}" required></textarea>
  50. </div>
  51. <div class="form-group mb-0 text-right">
  52. <button type="submit" class="btn btn-primary">{{ translate('Send') }}</button>
  53. </div>
  54. </form>
  55. </div>
  56. </div>
  57. @endsection
  58. @section('script')
  59. <script type="text/javascript">
  60. function refresh_messages(){
  61. $.post('{{ route('seller.conversations.refresh') }}', {_token:'{{ @csrf_token() }}', id:'{{ encrypt($conversation->id) }}'}, function(data){
  62. $('#messages').html(data);
  63. })
  64. }
  65. refresh_messages(); // This will run on page load
  66. setInterval(function(){
  67. refresh_messages() // this will run after every 5 seconds
  68. }, 4000);
  69. </script>
  70. @endsection