0
我在laravel中使用'Auth ::'有困難,我試圖讓它工作,因此它檢查用戶ID,然後顯示使用該用戶標識的所有約會。在預約表,它使用「USER_ID」Laravel - 試圖獲得非對象的財產(麻煩認證::)
ErrorException在AppointmentController.php線22: 試圖獲得非對象的屬性
約會控制器(這是錯誤的行)
function index()
{
$appointments = Appointment::where('user_id', Auth::user()->id);
return view ('appointment/userappointments',['appointments' => $appointments]);
}
userappointments.blade
@extends('layouts.master')
@section('title', 'Appointments')
@section('content')
<h1>Your Appointments</h1>
@foreach ($appointments as $appointment)
<p>
<a href="{{url('details/'.$appointment->id)}}" >{{$appointment->doctor->name}} : {{$appointment->time}} : {{$appointment->date}}</a>
</p>
@endforeach
@endsection