DekGenius.com
PHP
laravel Route::group definition
Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
Route::get('/', 'AccountController@index')->name('index');
Route::get('connect', 'AccountController@connect')->name('connect');
});
Route::group(['prefix'=>'quotes','as'=>'quote.'], function(){
Route::get('/', 'QuoteController@index')->name('index');
Route::get('connect', 'QuoteController@create')->name('create');
});
laravel grouping routes
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
// Uses first & second middleware...
});
Route::get('/user/profile', function () {
// Uses first & second middleware...
});
});
route group controller laravel
use AppHttpControllersOrderController;
Route::controller(OrderController::class)->group(function () {
Route::get('/orders/{id}', 'show');
Route::post('/orders', 'store');
});
laravel route group name
Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
Route::get('/', ['as' => 'index', 'uses' => 'AccountController@index']);
Route::get('connect', ['as' => 'connect', 'uses' = > 'AccountController@connect']);
});
laravel group routes
Route::group(['prefix' => 'admin'], function () {
Route::get('users', function () {
// Matches The "/admin/users" URL
});
});
laravel group route controller
Route::controller(DeviceApiController::class)
->prefix('/devices')
->as('devices.')
->group(function () {
Route::get('/index', 'index')->name('index');
Route::get('/{serialNumber}/show', 'show')->name('show');
});
grouping route in laravel
Route::group(['middleware' => ['auth', 'checkOnboarding']], function () {
Route::get('/home', 'HomeController@index');
Route::get('/account', 'AccountController@index');
});
Route::group(['prefix' => 'setup', 'middleware' => 'auth'], function () {
Route::get('/', 'OnboardingController@index')->name('setup');
Route::post('/settings', 'SettingsController@store');
});
route group in laravel
Route::group(['prefix' => 'admin']){
Route::get('/',function(){
//...
});
}
grouping route in laravel
Route::group(['middleware' => 'auth'], function () {
Route::group(['middleware' => 'checkOnboarding'], function () {
Route::get('/home', 'HomeController@index');
Route::get('/account', 'AccountController@index');
});
Route::group(['prefix' => 'setup'], function () {
Route::get('/', 'OnboardingController@index')->name('setup');
Route::post('/settings', 'SettingsController@store');
});
});
laravel route group
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
// Uses first & second middleware...
});
Route::get('/user/profile', function () {
// Uses first & second middleware...
});
});
laravel Route group within a group
Route::group(['prefix' => 'user', 'as' => 'user.'], function() {
Route::get('login', 'UserController@login');
Route::get('register', 'UserController@register');
Route::group(['middleware' => 'auth'], function() {
Route::get('edit', 'UserController@edit');
});
});
© 2022 Copyright:
DekGenius.com