I am using eloquent as part of a slim 3 project with slim-jwt-auth (https://github.com/tuupola/slim-jwt-auth), outside of Laravel. There are many situations where I want to control the items returned based on the user who is making the request.
From what I understand though, there is no way to add extra parameters such as user_id
for use in eloquent global scope.
I found one blog post that initially looked helpful, as it does exactly what I am trying to achieve (http://www.sdavara.com/Eloquent-Global-Scopes-A-cool-and-easy-way-to-fetch-loggedin-user-data/), but it relies on Laravel Auth.
The fact that my solution needs to work globally is important, as I have many nested relationships that should also be filtered by user id when queried.
Could anyone suggest what might be the best approach for achieving this?