resourceful controller laravel code example

Example 1: how to create controller in laravel

php artisan make:controller PhotoController --resource

Example 2: Route::resource('/posts','PostController');

Route::resources([
    'photos' => 'PhotoController',
    'posts' => 'PostController',
]);

Example 3: laravel create resource controller

php artisan make:controller PhotoController --resource --model=Photo

Example 4: laravel create resource controller

Route::resource('photos', 'PhotoController');

Example 5: resource controller laravel

Route::resource('photos', PhotoController::class);

Tags:

C Example