기본 약속 시스템을 만들려고합니다. 사용자가 로그인하면 if
성명에는 개인 약속이 표시되어야하지만 현재는 모든 사람의 약속이 표시됩니다.foreach 루프 내에서 if 문을 사용하는 경우
if
문의 목적은 이러한 약속이 내
appointments
테이블이
user_id
을 가지고 있으며, 내
users
테이블 단지를 가지고
가이 사용자 ID를 사용하는 모든 약속을하고 표시 있는지 확인하기 위해 자신의 사용자 ID를 확인하는 것입니다
일반 id
. 같은 appointment->user_id
과 appointment
관련된 user->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