0

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

Sam Leumas
  • 23
  • 5

3 Answers3

0

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');
maki000
  • 339
  • 1
  • 8
0
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.

Saugat Jonchhen
  • 356
  • 5
  • 16
Aachhyo
  • 69
  • 1
  • 3
0

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().

Vivek Pawar
  • 664
  • 5
  • 11