Laravel route not calling function of controller

Viewed 5672

I have a form in a page (blade) which redirects to a route which is to call a function in a controller however it does not even go inside the function because even a simple dd(); cannot be executed. when in route, if I change to

Route::post('edit/profile', function(Request $request){
dd($request);
});

it works. I tried to change both route's function name and controller's function name to another name still doesn't recognize.

My current route

Route::post('edit/profile', 'Auth\LoginController@updateUser');

My form line

<form action="{{url('/edit/profile')}}" method="post">
{{ csrf_field() }}

My function inside LoginController

public function updateUser(Request $request)
{
    //insert code here
}
1 Answers

I know it's late, but did you solve the problem? I've had a simmilar issue, inside auth group a route was not working. In my case, I had to put the route after the "Route::resource". So make sure if your are making a route that has a resource tagged, add the other routes before the Route::resource. For example:

Route::group(['middleware' => ['auth']], function() { 
   Route::resource('category', 'CategoryController');
   Route::get('category/order', 'CategoryController@order')->name('categoryOrder');
});

This won't work. Just put the 'category/order' route before the resource route like this:

Route::group(['middleware' => ['auth']], function() { 
   Route::get('category/order', 'CategoryController@order')->name('categoryOrder');
   Route::resource('category', 'CategoryController');
 });

This should work. Hope this helps someone.

Related