I am using Laravel Passport (auth:api
), all works well however I've came with the idea to log record user requests on a specific route.
When an GET
request is made to /movie/65
I would like to store in movie_view
the following data: user_id
, movie_id
(if the user is logged in)
However in my controller I am unable to call $request->user()
without setting auth:api
middleware.
What is the best practice you recommend to achieve this?
Default Auth Type should be set to 'api' in config/auth.php
Source: https://laracasts.com/discuss/channels/general-discussion/optional-authentication-for-api?page=0 (it was very hard to find)