Do you have an error ?
Is the authenticated user fill his phone number?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I have following table like students
id name email telephone user_id
1 anne [email protected] 07115550096 5
user_id is related to id of users table.
now I need print all name, email and telephone data witch related to login user id. I have following controller function for that
public function index()
{
$students = Student::personal()->get();
return view('students.index')->withStudents($students);
}
and Student Model
public function scopePersonal($query)
{
return $query->where('user_id', Auth::user()->id);
}
using above syntax I am printing data as following,
{{Auth::user()->name}}
{{Auth::user()->email}}
{{Auth::user()->telephone}}
but it is not printing telephone value
@FLEX - I didn't see... you request on Auth::user(), and the information is on $students.
If you set the relation, you can try Auth::user()->student->telephone
Please or to participate in this conversation.