Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Inpanic4's avatar

make a query in controller

Hello , i am trying to pass all the dissertations where exists on my DB from the specific Auth::user, connected with internal_examiner_id which is user's id. in this line 'dissertations' =>Dissertation::all()->where('internal_examiner_id','12'), I am trying to make the number 12 dynamic, i want to use the Auth::user's id, ive tried Auth::user()->id,tried to make a variable called $query = auth()->user()->id; and pass it instead of 12 and some other ways with no luck.. Any suggestions? ​```

0 likes
2 replies
MichalOravec's avatar
Level 75
$dissertations = Dissertation::where('internal_examiner_id', auth()->id())->get();

or with a relationship

$dissertations = auth()->user()->dissertations()->get();
1 like

Please or to participate in this conversation.