Reputation: 11
I am using Laravel 5.5 version. I defined my routes in the routes.php
file. like this:-
$router->group(['middleware' => 'auth'], function($router) {
$router->resource('/route-name', 'myController@myMethodName');
});
But when I run my application laravel gives error:-
Method [myMethodName@index]
does not exist on [App\Http\Controllers\myController]
.
It is by default put index action after my defined action in the routes.
It is working fine in the laravel 5.3 version. Please solve my problem..
Upvotes: 1
Views: 570
Reputation: 432
By Default resource
Request create CRUD
requests in routes. For the following methods in Controller
.
You can't pass method name in resource
route.
If you want to override any of them. you have to write new one
route
below theresource
Route. Like
Route::get('url','Controller@newMethod');
And Change the method name in Controller with newMethod
For more detail check laravel documents
Upvotes: 0
Reputation: 2416
Try this as @devk told in comment:
$router->get('/route-name', 'myController@myMethodName');
Upvotes: 1