1// Implicit Model Binding Routes can be created with one line using either:
2Route::resource('photos', PhotoController::class);
3// OR
4Route::resources([
5 'photos' => PhotoController::class,
6 'posts' => PostController::class,
7]);
8
9php artisan make:controller PhotoController --resource --model=Photo
10 // makes a controller with stubouts for methods:
11 // index
12 // create
13 // store
14 // show
15 // edit
16 // update
17 // destroy
1Route::resources([
2 'photos' => 'PhotoController',
3 'posts' => 'PostController',
4]);
1By default, all resource controller actions have a route name;
2however, you can override these names by passing a names array
3with your desired route names:
4
5use App\Http\Controllers\PhotoController;
6
7Route::resource('photos', PhotoController::class)->names([
8 'create' => 'photos.build'
9]);
1Verb Path Action Route Name
2GET /users index users.index
3GET /users/create create users.create
4POST /users store users.store
5GET /users/{user} show users.show
6GET /users/{user}/edit edit users.edit
7PUT|PATCH /users/{user} update users.update
8DELETE /users/{user} destroy users.destroy