Current File : /home/tradevaly/public_html/resources/views/user/pages/inbox.blade.php
@extends('user.ayaan.master')

@push('style')
    
@endpush

@section('content')
<div class="container-fluid">
  <div class="row">
    <div class="col-md-12">
      <div class="card">
        <div class="card-header card-header-info card-header-icon">
          <h4 class="card-title">Messages</h4>
        </div>
        <div class="card-body">
          <div class="table-responsive">
            <table class="table">
              <thead>
                <tr>
                  <th class="text-center">#</th>
                  <th>Title</th>
                  <th>Sender</th>
                  <th>Receiver</th>
                  <th>Last Reply</th>
                  <th>Last Messages Time</th>
                </tr>
              </thead>
              <tbody>
                @php
                   $i = 0;
                @endphp
                @foreach ($offers as $product)
                <tr>
                    
                    
                    
                  <?php $i++; 
                  $msg = \App\Models\Message::where('thread_id', $product->id)->orderBy('created_at', 'desc')->first();
                  if(!empty($msg)){
                      echo 'user not found';
                  }
                  ?>
                  <td class="text-center">{{$i}}</td>
                  <td><a href="{{route('user.inbox.view', $product->id) }}">{{$product->subject}}</a></td>
                  <td>
                  {{$product->sender->name ?? ''}}
                  </td>
                  <td>
                  {{$product->receiver->name ?? ''}}
                  </td>
                  
                  @if($msg != null)
                 <td>
                  {{$msg->sender ?  $msg->sender->name:''}}
                  </td>
                  <td>
                  {{date('d F, Y h:i', strtotime($msg->created_at))}}
                  </td>
                  @else
                  <td>
                      
                  </td>
                  <td>
                      
                  </td>
                  @endif
                </tr>
                @endforeach
              </tbody>
            </table>
          </div>
        </div>
      </div>
  </div>
</div>
@stop

@push('script')
   
@endpush