mardi 24 juillet 2018

Laravel Route resource named functions

I currently have routes like this

//Settings
Route::prefix('settings')->group(function(){
    //Get all users settings
    Route::resource('user', 'SettingsController');
});

Which will produce a list of routes like so

| POST      | settings/user                     |user.store   | App\Http\Controllers\SettingsController@store                              | web,auth,GlobalAdmin        |
| GET|HEAD  | settings/user                     |user.index   | App\Http\Controllers\SettingsController@index                              | web,auth,GlobalAdmin        |
| GET|HEAD  | settings/user/create              |user.create  | App\Http\Controllers\SettingsController@create                             | web,auth,GlobalAdmin        |

And so on.

My issue is that I want the settings controller to be able to control a list of different settings in 1 controller, not just 'users'.

How would I name the resource so that it names the functions at the end?

For example, the above code generates function names like SettingsController@store, how would i get it so that it auto builds the function name with a prefix like SettingsController@userstore?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire