Reputation: 22489
I just wondering in my project. I have a form that can be access at localhost/app/esetting/mymail
and this is the code in the view:
....
<form action="{{ url( 'app/esetting/emailautomsave' ) }}" class="form-horizontal" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
...
<input type="submit" value="save">
</form>
but when I try to click for form submission, I expect it to go to app/esetting/emailautomsave
and calls it controller which is on my SettingsController.php
.
public function postEmailautomsave(Request $request){
...
}
but it redirects to localhost/app/mymail
? and give me this error:
NotFoundHttpException in Controller.php line 93:
Controller method not found.
this sounds weird on my end. can anyone have an idea about this? I am sure I have done the right this specially on my routes.php
Route::group([ 'prefix' => 'app', 'middleware' => 'auth' ], function() {
....
Route::controller('esetting', 'SettingController');
Route::get( 'esetting/mymail', 'SettingController@viewEmailAutom' ); // view for the form to display
....
Upvotes: 0
Views: 645
Reputation: 196
If you use Route::controller you need to define you methods according to the route. E.g.
Route::controller('esetting', 'SettingController');
Will look for SettingController@getIndex when you visit http:://yoursite.com/esetting
To reach SettingController@postEmailAutomsave() you would need to go to the route http:://yoursite.com/esetting/emmail/automsave
I have not used Route::controller myself, I got used too (and now prefer) naming them individually. But this should do the trick.
Upvotes: 0
Reputation: 19372
Just simply define:
Route::post('esetting/mymail/emailautomsave', 'SettingController@postEmailautomsave');
I know that You'll say: "I've defined Route::controller, so it will look for it atuomatically."
But for me is best to have routes defined exactly.
also if:
it redirects to localhost/app/mymail? and give me this error:
NotFoundHttpException in Controller.php line 93: Controller method not found.
maybe it means that some middleware is redirecting You there?
You can check it by simply doing this:
public function postEmailautomsave(Request $request){
die('test');
...
}
if it will redirect so it mean that some function was called before and redirect browser to app/mymail
.
Upvotes: 1