Am trying to use two different functions from one controller in a single page route
Route::get('/cart','App\Http\Controllers\Frontend\CartController@index');
Route::get('/cart','App\Http\Controllers\Frontend\CartController@alldata');
But the problem is the function alldata works where the function index doesn't
CodePudding user response:
Route::get('/cart','App\Http\Controllers\Frontend\CartController@index'); Route::get('/cart','App\Http\Controllers\Frontend\CartController@alldata');
Try to manipulate your logic in controller rather than in route file. Use conditional in controller function.
CodePudding user response:
You can't have 2 GET routes with the same path.
Route::get('/cart','App\Http\Controllers\Frontend\CartController@index');
Route::get('/cart/all','App\Http\Controllers\Frontend\CartController@alldata');
CodePudding user response:
The /cart route is overwritten by the alldata(). So the alldata() is calling instead of index().
kindly remove the alldata()'s route and pass the data from index().
