I'm building and application in Laravel
and Vuejs
where I'm having Laravel routes as below:
Route::get('/admin/{view?}', 'HomeController@admin')->where('view', '(.*)')->name('admin');
Route::get('/{view?}', 'HomeController@home')->where('view', '(.*)')->where('view', '!=', 'admin')->name('home');
I'm using Vue-router
so I'm having routing in vuejs, and I'm using history mode. The problem is when I try to call /admin
it generally calls HomeController@home
method. even if I go deeper like /admin/dashboard
it is calling the same home
method. I want if admin
prefix is being called then it should call HomeController@admin
method.
its all okay for me please check this
Route::get('/admin/{view?}', function (){
dd('okay');
})->where('view', '(.*)')->name('admin');
Route::get('/{view?}', function(){
dd('okay1');
})->where('view', '(.*)')->name('home');
So try this
Route::get('/admin/{view?}', 'HomeController@admin')->where('view', '(.*)')->name('admin');
Route::get('/{view?}', 'HomeController@home')->where('view', '(.*)')->name('home');