File api.php:

$api->version('v1', function ($api) { $api->get('todos', 'App\Http\Controllers\Admin\TodoController@index'); $api->post('todos', 'App\Http\Controllers\Admin\TodoController@store'); //ну и так далее }); 

How to use middleware to check whether the user is logged in when he tries to enter the admin area via api?

    1 answer 1

    Assuming you are using the dingo/api package, this is what the documentation says:

     $api->version('v1', ['middleware' => 'foo'], function ($api) { // маршруты }); 

    Where foo is the middleware that checks if the user is logged in.