Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

That will create 3 routes because it offers both put and patch routes for updating.

|GET|HEAD|settings           |settings.index |App\Http\Controllers\SettingsController@index |
|PUT     |settings/{settings}|settings.update|App\Http\Controllers\SettingsController@update|
|PATCH   |settings/{settings}|               |App\Http\Controllers\SettingsController@update|

You can see based on the second column that you need to pass an argument on update. For example, maybe you pass in the ID of the setting, and in your controller, you can accept that ID.

Link to docs: http://laravel.com/docs/5.1/controllers#restful-resource-controllers

Last updated 9 years ago.
0

--- EDIT---

OK I follow you now, thanks, the little table in the link makes sense now.

Thanks once again :)

Sorry I do not follow, there is no $id being passed as its tied direct to the $auth->id so nothing gets passed (1 to 1 relation) so when a user registers setting are default 0 or 1 in the database, if they change and save the controller will get the correct auth'd user and update their settings.

I only have 2 methods, in the controller index() and update() so i thought rather than typing out each specific GET and PUT like:

Route::get('settings', array(
    'uses' => 'SettingsController@index')
  ); 

  Route::put('settings', array(
    'uses' => 'SettingsController@update')
  );

it was easier to simply declare it as a resource and map out the only 2 options in 1 line.

SIDE NOTE::

When I run php artisan route:list i end up with The token could not be verified from the request.

So at the moment I can not even list the current routes to see so that another thing I am sorting out.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.