Laravel Resources routes performace or benefits

901 views laravel routes
7

Does the laravel Resource Route give ANY benefit over the 'normal' way of writing routes other than saving time?

ex

Route::get('something', 'MyController@index')->name('app.index');
Route::put('something/{thing}', 'MyController@store')->name('app.store');
Route::get('something/{thing}', 'MyController@show')->name('app.show');

vs

Route::resource('something','MyController')

answered question

1 Answer

5

The benefit is, that you don't have to write them by yourself. If you are using a Resource Controller or a Controller with Resource logic, the Resource Routes come in handy. You can even use partial Resource Routes.

The downside is, that you will need to apply Route specific Middleware in your Controller.

https://laravel.com/docs/7.x/controllers#resource-controllers

posted this

Have an answer?

JD

Please login first before posting an answer.