Level 104
Typically, I would use a relationship in similar cases:
auth()->user()->workerTests;
But it amounts to the same thing really. The route(s) that use this Controller method would be protected by auth middleware of course.
Also, you can get the id for the authenticated user using Auth::id() or auth()->id() which looks a little cleaner to my eye.
1 like