framework: Partial Resource Routes only() except() why throw an error instead of 404 ?

  • Laravel Version: 5.6
  • PHP Version: 7.1.19

Description:

https://laravel.com/docs/5.6/controllers#resource-controllers

when i create a controller by php artisan make:controller TestController --resource --model=Test and use route: Route::resource('/test', 'TestController')->only(['index', 'store', 'edit', 'update', 'destroy']); or Route::resource('/test', 'TestController')->except(['create', 'show']);

if go to http://example.com/test/1 (actually this is route test.show) why throw an error instead of 404? Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 17 (3 by maintainers)

Most upvoted comments

You code was wrong

Route::resource('/test', 'TestController', ['only' => ['index', 'store', 'edit', 'update', 'destroy']]);

Route::resource('/test', 'TestController', ['except' => ['create', 'show']]);

so what the ->except() used for ?

and /test/create is not in the route:list