Hello to all, welcome to therichpost.com. In this post, I will tell you, What is the use of Prefix in Laravel Routes? I am doing with laravel first time in my website. Laravel is one of the top php mvc framework.
I personally like laravel routes feature very much.
By my understanding in basic way, laravel prefix works as if we have same route(uri) with multiple queries or fuctions in same controller
routes/web.php file:
Route::group([‘prefix’ => ‘user’], function() {
Route::get(‘/’, ‘UserController@index’);
Route::post(‘/get-business-hours’, ‘UserController@getBusinessHours’)->middleware(‘ajax’);
Route::get(‘/get-all-bookings’, ‘UserController@getAllBookings’)->middleware(‘ajax’);
Route::post(‘/get-product-categories’, ‘UserController@getProductCategories’)->middleware(‘ajax’);
Route::post(‘/get-products’, ‘UserController@getProducts’)->middleware(‘ajax’);
Route::post(‘/checkout’, ‘UserController@handleCheckout’)->middleware(‘ajax’);
});
In controller file app/Http/Controllers/UserController.php:
public function getBusinessHours(Request $request)
{}
public function getAllBookings(Request $request)
{}
public function getProductCategories(Request $req)
{}
public function getProducts(Request $req)
{}
public function handleCheckout(Request $req)
{}
There are so many code tricks in laravel and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com
Recent Comments