1

I have this route:

Route::get('/', function () {
    return view('index');
});

Route::resource('admin', 'EmployeeController');

I have model Employee and EmployeeController( with empty resource methods)

Error : Call to undefined method Illuminate\Routing\ResourceRegistrar::addResourceEmployee()

What is wrong with my code? I have used the same approach in other project and it worked.

Gunel
  • 23
  • 1
  • 8
  • This error came on which route???? – Manish Yadav Jun 17 '17 at 15:09
  • in all routes, when i delete resource route it works @ManishYadav – Gunel Jun 17 '17 at 15:11
  • did you created the controller using the `artisan` command or manually – Manish Yadav Jun 17 '17 at 15:13
  • yes, php artisan make:migration EmployeeController --resource @ManishYadav – Gunel Jun 17 '17 at 15:15
  • it's `php artisan make:controller` not `make:migration`. make migration is used to create database migrations. Use this command `php artisan make:controller EmployeeController --resource` to create your controller – Manish Yadav Jun 17 '17 at 15:15
  • i have created controller as **php artisan make:controller EmployeeController --resource** i made mistake previous comment / all have been already created and problem is resource not working @ManishYadav – Gunel Jun 17 '17 at 15:53

1 Answers1

0
Route::resource('admin', 'EmployeeController');

is attempting to bind to a model named Admin.

Route::resource('employees', 'EmployeeController');

should work with the model you have. To make it work with admin, name the resource parameter.

Route::resource('admin', 'EmployeeController', ['parameters' => [
    'admin' => 'employee'
]]);

edit

Did you reference something outside the Laravel docs to use AddResourceEmployee(). Seems like a custom solution to me.

https://stackoverflow.com/a/16661564/320487

  • Where is `addResourceEmployee()` being defined? Did you extend the `Router` class? The reference I've found is others extending the class to add those static methods themselves. See: http://techqa.info/programming/question/16661292/add-new-methods-to-a-resource-controller-in-laravel –  Jun 17 '17 at 15:52