UserModel
has a relation to a Doctor
:
public function doctor() {}
The next way is working:
Auth::user()->doctor->name
How to use eager loading like this:
Auth::user::with('doctor')->name
CodePudding user response:
You need to actually return the result(s) of calling your relationship:
$doctor = Auth::user::with('doctor')->first();
dd($doctor->name);