flyingL123
flyingL123

Reputation: 8076

Laravel resource controller additional route

In the Laravel documentation on resource controllers (http://laravel.com/docs/controllers#resource-controllers), there is a section titled "Adding Additional Routes To Resource Controllers".

It says to add a route before the resource route is declared. So, in my route.php file I have this:

Route::get('faq/data');
Route::resource('faq', 'ProductFaqController');

After adding the first line show above, my /faq route no longer works. I receive the following error:

Missing argument 2 for Illuminate\Routing\Router::get(), called in /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 208 and defined

Is the documentation wrong? How can I add an additional route to my resource controller? I would like to add a route to /faq/data that will respond to a GET request.

Upvotes: 0

Views: 1300

Answers (1)

marcanuy
marcanuy

Reputation: 23972

You are missing the action, what should faq/data do?

Route::get('faq/data', function()
{
    return 'Hello World';
});

or to a Controller method

Route::get('faq/data', 'MyController@showHelloWorld');

Upvotes: 1

Related Questions