1You're trying to redirect to a named route whose name is login, but you have
2no routes with that name:
3
4Route::post('login', [ 'as' => 'login', 'uses' => 'LoginController@do']);
5
6The 'as' portion of the second parameter defines the name of the route. The
7first string parameter defines its route.
1To check either request includes token or not make your own middleware.
2
3php artisan make:middleware CheckApiToken
4
5public function handle($request, Closure $next)
6{
7 if(!empty(trim($request->input('api_token')))){
8
9 $is_exists = User::where('id' , Auth::guard('api')->id())->exists();
10 if($is_exists){
11 return $next($request);
12 }
13 }
14 return response()->json('Invalid Token', 401);
15}