Laravel Group routing

For common prefixes in a url, Laravel uses url grouping.

Route::group(['prefix'=>'user','as'=>'user.'], function(){

	Route::get('my-profile', 
	['as' => 'profile', 
	'uses' => 'UserController@myProfile']
	);

	Route::post('my-profile', 
	['as' => 'putprofile', 
	'uses' => 'UserController@putMyProfile']);

});

In the above route addresses

abc.com/my-profile

In GET and POST method

you can use print GET route as :-

route(user.profile)

And, POST route as:-

route(user.putprofile)

Leave a Reply

Your email address will not be published. Required fields are marked *