
Laravel 9 route group with controller
You can group all the routes which utilize the same controller using controller method in Laravel 9.
Answers 1
-
Route grouping with controller
--PATH routes\web.phpuse App\Http\Controllers\OrderController; Route::controller(OrderController::class)->group(function () { Route::get('/orders/{id}', 'show'); Route::post('/orders', 'store'); });
0If a group of routes uses the same controller then you can group all the routes using the controller method.
Additional Note:
1. Create OrderController using php artisan command - php artisan make:controller OrderController
2. Import/use controller in routes/web.php using use App\Http\Controllers\OrderController;
Random Code Snippet Queries: Laravel
- First and last item of the array using foreach iteration in laravel blade
- OrderBy on Eloquent relationships method in Laravel
- How to display pivot table column value in laravel
- Class 'App\Http\Controllers\User' not found
- Insert data with form validation using ajax in laravel
- Get domain name in laravel
- Method Illuminate\Database\Eloquent\Collection::appends does not exist
- Check if Relationship Method Exists in Laravel
- Class 'App\Providers\Auth' not found
- Call to a member function pluck() on array
- How to return a column with different name in Laravel
- Ajax POST request in laravel
- Laravel save object to database
- Get id of last inserted record in laravel
- How to create new user without form submission in laravel
- Insert current date time in a column using Laravel
- How to create and run user seeder in laravel
- Send post data from controller to view
- How to disable timestamps in laravel
- The use statement with non-compound name 'Auth' has no effect
- PhpMyAdmin - Error The mysqli extension is missing
- Attempt to read property "avatar" on null in Laravel
- Insert Comma Separated Values in laravel
- How to delete record in Laravel with ajax
- Get last record from table in laravel