I'm trying to create a basic appointment system. When a user logs in, an if statement should display their personal appointments, but at the moment it's displaying everybody's appointments.
The aim of the if statement is to check their user ID to see if there are any appointments that use this user ID and display these appointments
My appointments table has a user_id, and my users table just has a regular 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