I have a basic appointment system set up, however everybody logged in can see all appointments, so what I'm trying to do is make it so users can only see their appointments. To do this I'm trying to get the logged in users Id then display all the appointments that have this user_id value (Appointments is a junction table)
I know my code is probably awful but any help is appreciated, thanks
function index()
{
$logged_user_id = Auth::user()->id;
$user = User::find($logged_user_id);
$appointments = Appointment::where('user_id', '=' $user)->get();
return view ('appointment/userappointments',['appointments' => $appointments]);
// $appointments = Appointment::all();
}
auth()->user()->appointments