I'm wondering how to have a policy on the user model.
I understand that the first argument is the authenticated user, however I want to obtain the user in the route. When I add the 2nd argument, it'll only pass in 1 argument and error.
I have an API with the endpoint POST /users/{user}/something
class UserPolicy
{
use HandlesAuthorization;
public function show(User $user, User $routeUser)
{
// Type error: Too few arguments to function UserPolicy::show(), 1 passed in and exactly 2 expected"
}
}
I suspect the fact that the route wildcard is $user and the second argument is $routeUser is an issue. Can you rename the first argument $authUser and the second to match the route wildcard, i.e. $user?