@extends ('layouts/template')

@section('content')
    <div class="m-2">
        <div class="card-body p-0 h-100">
            <table class="table table-sm">
                <thead>
                <tr>
                    <th>Created At</th>
                    <th>Message</th>
                    <th>Regarding Client</th>
                    <th>From Pro</th>
                    <th>Regarding Company</th>
                </tr>
                </thead>
                <tbody>
                @foreach($messages as $message)
                <tr>
                    <td>{{friendlier_date_time($message->created_at)}}</td>
                    <td>{{$message->content_text}}</td>
                    <td>
                        @if($message->regardingClient)
                        <a href="/patients/view/{{$message->regardingClient->uid}}/messages">
                            {{$message->regardingClient?$message->regardingClient->displayName():''}}
                        </a>
                        @endif
                    </td>
                    <td>{{$message->fromPro?$message->fromPro->displayName():''}}</td>
                    <td>{{$message->regardingCompany? $message->regardingCompany->name : ''}}</td>
                </tr>
                @endforeach
                </tbody>
            </table>
            <div>
                {{$messages->withQueryString()->links()}}
            </div>
        </div>
    </div>
@endsection
