Reputation: 8160
When I use my route like this, the test
route is working fine.
Route:-
Route::group(array('namespace' => '\User'), function () {
Route::get('user/my-favorite','UserController@myFavorite');
Route::get('user/test','UserController@test'); // is working
Route::resource('user', 'UserController');
Route::group(['middleware' => ['auth']], function () {
Route::get('user/planed',['as' => 'user.planed', 'uses' => 'USerController@planed']);
.
.
.
.
But when I want to use it like following, it shows a blank page :
Route::group(array('namespace' => '\User'), function () {
Route::get('user/my-favorite','UserController@myFavorite');
Route::resource('user', 'UserController');
Route::group(['middleware' => ['auth']], function () {
Route::get('user/planed',['as' => 'user.planed', 'uses' => 'UserController@planed']);
Route::get('user/test','UserController@test'); // is not working
.
.
.
.
What is my mistake?
Upvotes: 1
Views: 561
Reputation: 15529
Because the call to test is intercepted by
Route::resource('user', 'UserController');
because if you check the routes in the console with
$> php artisan route:list
you'll see it includes
GET|HEAD | user/{user}
and then your first route
Route::get('user/test','UserController@test'); // is not working
is never reached. Try to put it BEFORE the other line.
Upvotes: 1
Reputation: 4894
I thing the issue in naming the route check This
Try like this
Route::group(array('namespace' => '\User'), function () {
Route::get('user/my-favorite','UserController@myFavorite');
Route::resource('user', 'UserController');
Route::group(['middleware' => ['auth']], function () {
Route::get('user/planed','UserController@planed'])->name('user.planed');
Route::get('user/test','UserController@test'); // is not working
Just replace
Route::get('user/planed',['as' => 'user.planed', 'uses' => 'UserController@planed']);
With
Route::get('user/planed','UserController@planed'])->name('user.planed');
Upvotes: 1