I use passport for api authentication and i configure auth.php api gaurd to passport.
Some of my route APIs are in auth:api group. I send Authorization header with access token and it check user very well.
But the problem is that, this mechanism works well in Route::post method and \Auth::user()->id return user id,
but in Route::resource \Auth::user() returns null.
I double checked everything and it seems Route::resource ignore "auth:api" middleware. I also tested middleware in __construct method of my resource controller. Nothing changed. Thank you for further help.
Route::group(['middleware' => ['auth:api']],function (){
Route::post('update',['uses'=>'C_Update@handle']);
Route::resource('contacts','C_Contacts',['only'=>['index','store','update','destroy']]);
});
Route::resource
literally isn't doing anything more than registering the 7 routes you could manually register. – lagbox