Search code examples
phplaravelscaffolding

Scaffolding with Laravel


I am relativley new to laravel, and have created an 'article' scaffold using this plugin:

https://github.com/JeffreyWay/Laravel-4-Generators

And running:

php artisan generate:resource article --fields="title:string, body:text"

Everything works out fine, with the table being created in my database and the associated files appearing in my project directory. However, when I navigate to localhost/laravel/public/articles (my directory), I get the following error:

ErrorException (E_NOTICE)
HELP
Undefined offset: 1
Open: C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Routing\Router.php
            $route = $this->current();

            $request = $this->getCurrentRequest();

            // Now we can split the controller and method out of the action string so that we
            // can call them appropriately on the class. This controller and method are in
            // in the Class@method format and we need to explode them out then use them.
            list($class, $method) = explode('@', $controller);

            return $d->dispatch($route, $request, $class, $method);

I tried running

php artisan optimize --force

but this didn't help.

Any advice?


Solution

  • you must add route for article like this:

    Route::resource('articles', 'ArticlesController');
    

    in app/routes.php file.