我試圖創建一個基本的預約系統。當用戶登錄時,if
聲明應顯示其個人約會,但此時它顯示每個人的約會。如果語句在一個foreach循環中
的if
聲明的目的是檢查自己的用戶名,看是否有使用該用戶ID的任何任命,並顯示這些任命
我appointments
表有user_id
,我users
表只是有一個定期id
。
@section('content')
<h1>Your Appointments</h1>
@foreach ($appointments as $appointment)
@if ($appointment->user->id == $appointment->user_id)
<p>
<a href="{{url('details/'.$appointment->id)}}" >{{$appointment->doctor->name}} : {{$appointment->time}} : {{$appointment->date}}</a>
</p>
@endif
@endforeach
@endsection
這很好,謝謝! – TF120