Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

in laravel , what is the differace between Route::resource and Route::get?

in laravel 9 , what is the difference between

Route::resource('/blog',[PostController::class);

and

Route::get('/blog',[PostController::class,'index']);

?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Resource route will generate all CRUD routes:

Verb          Path                       Action  Route Name
GET           /blog                      index   blog  index
GET           /blog/create               create  blog  create
POST          /blog                      store   blog  store
GET           /blog/{post}               show    blog  show
GET           /blog/{post}/edit          edit    blog  edit
PUT|PATCH     /blog/{post}               update  blog  update
DELETE        /blog/{post}               destroy blog  destroy

Second variant will generate only one GET route (first in list)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading