Hello everyone,
I'm creating an API with authentication of Laravel Passport. but I'm getting this error.
Array to string conversion in file /var/www/html/laravel-passport-api/vendor/laravel/framework/src/Illuminate/Routing/ResourceRegistrar.php on line 630
whenever I'm adding middleware('auth:api') in the api route file.
@akash_kushwaha You are probably confusing the syntax for regular routes with the syntax for resource controllers.
For resource controllers you have to pass the class name as a string:
Route::resource('/products', [Productcontroller::class])->middlerware('auth:api');
// remove the array from controller
Route::resource('/products', PrderController::class)->middlerware('auth:api');