Laravel Route

By ukmodak | March 31st 2024 10:38:02 AM | viewed 1125 times

How to setup Laravel Root

We can setup route in two ways. One:- using middleware(to restricted page according roles,permission and declaring route/path). Two:-declaring route/path

Add the following code in Http/routes.php


          // using only route/path
	Route::get('/', ['uses'=>'Auth\UserController@create','as'=>'/']);   // public home page
	
	Route::get('user/create',['uses' => 'Auth\UserController@create', 'as' => 'user/create']);
	Route::post('user/store/{ct}/{uk?}',['uses' => 'Auth\UserController@store', 'as' => 'user/store/ct/uk']);
	Route::get('user/index',['uses' => 'Auth\UserController@index', 'as' => 'user/index']);
	Route::get('user/edit/{id}',['uses' => 'Auth\UserController@edit', 'as' => 'user/edit/id']);
	Route::post('user/update/{id}',['uses' => 'Auth\UserController@update', 'as' => 'user/update/id']);
	Route::get('user/delete/{id}',['uses' => 'Auth\UserController@destroy', 'as' => 'user/delete/id']);
	Route::get('user/addUserRole',['uses' => 'Auth\UserController@addUserRole', 'as' => 'user/addUserRole']);
	Route::post('user/userRoleStore',['uses' => 'Auth\UserController@userRoleStore', 'as' => 'user/userRoleStore']);
		
	Route::get('role/create',['uses' => 'Auth\RoleController@create', 'as' => 'role/create']);
	Route::post('role/store/{ct}/{uk?}',['uses' => 'Auth\RoleController@store', 'as' => 'role/store/ct/uk']);
	Route::get('role/index',['uses' => 'Auth\RoleController@index', 'as' => 'role/index']);
	Route::get('role/delete/{id}',['uses' => 'Auth\RoleController@destroy', 'as' => 'role/delete/id']);
    
	
	
       
	   
	   // or using middleware
	Route::get('/', ['uses'=>'Auth\UserController@create','as'=>'/']);   // public home page
	Route::get('user/create',['uses' => 'Auth\UserController@create', 'as' => 'user/create']);
	Route::post('user/store/{ct}/{uk?}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@store', 'as' => 'user/store/ct/uk']);
	Route::get('user/index',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@index', 'as' => 'user/index']);
	Route::get('user/edit/{id}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@edit', 'as' => 'user/edit/id']);
	Route::post('user/update/{id}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@update', 'as' => 'user/update/id']);
	Route::get('user/delete/{id}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@destroy', 'as' => 'user/delete/id']);
	Route::get('user/addUserRole',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@addUserRole', 'as' => 'user/addUserRole']);
	Route::post('user/userRoleStore',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\UserController@userRoleStore', 'as' => 'user/userRoleStore']);
		
	Route::get('role/create',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\RoleController@create', 'as' => 'role/create']);
	Route::post('role/store/{ct}/{uk?}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\RoleController@store', 'as' => 'role/store/ct/uk']);
	Route::get('role/index',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\RoleController@index', 'as' => 'role/index']);
	Route::get('role/delete/{id}',['middleware' => ['crsf','guest'],'roles' => ['user'],'uses' => 'Auth\RoleController@destroy', 'as' => 'role/delete/id']);
	 

bONEandALL
Visitor

Total : 26654

Today :3

Today Visit Country :

  • France
  • United States