Open myloveGy opened 6 years ago
Laravel 5.6 same issue
Adding bindings
middleware to route group solve problem
The exact problem is still existing in Laravel 8. Adding bindings middleware causes the following error:
Target class [bindings] does not exist.
For future references,
Adding 'bindings' middleware as a group to all routes like explained here works in Laravel 9.39.0, BUT after configuring the Kernel.php as is said here and this other change also in the Kernel.php
I believe this solves @lambasoft problem also.
Basically you should do this:
api.php
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
$api->group(['middleware' => 'bindings'], function($api) {
$api->get('confirm-account/{token}', [ConfirmAccountController::class, 'confirm'])->name('confirm-account')
->missing(fn() => response()->error(404, 'Token not found.'));
});
});
Kernel.php
...
protected $middlewareGroups = [
'web' => [
...
],
'api' => [
'throttle:api',
'bindings',
],
];
...
protected $routeMiddleware = [
...
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
...
];
Actual Behaviour
I do the following settings in the routing
I am on the controller below
My request http://www.demo.com/api/applys/11 Get the structure is null, but in fact there is data But when I route the following settings, the structure is normal
And the following is also problematic