How to define CRUD with only one line route in Laravel

Aug 24, 2020 PHP Laravel route Resources

You can design and design the routing of article-related functions such as the article posting screen and article registration processing by yourself.

Laravel provides methods that bundle routes for commonly used functions such as.

Route::resource('/articles','ArticleController');

Just defining it will set CRUD uri etc. at a stretch.

+--------+-----------+-------------------------+-- ----------------+--------------------------------- ---------------------------------------+---------- --+
Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+-------------------------+-- ----------------+--------------------------------- ---------------------------------------+---------- --+
| | GET|HEAD | / | | App\Http\Controllers\ArticleController@index | web |
| | POST | articles | articles.store | App\Http\Controllers\ArticleController@store | web |
| | GET|HEAD | articles | articles.index | App\Http\Controllers\ArticleController@index | web |
| | GET|HEAD | articles/create | articles.create | App\Http\Controllers\ArticleController@create | web |
| | DELETE | articles/{article} | articles.destroy | App\Http\Controllers\ArticleController@destroy | web |
| | PUT|PATCH | articles/{article} | articles.update | App\Http\Controllers\ArticleController@update | web |
| | GET|HEAD | articles/{article} | articles.show | App\Http\Controllers\ArticleController@show | web |
| | GET|HEAD | articles/{article}/edit | articles.edit | App\Http\Controllers\ArticleController

It’s very convenient, so please try it.

That’s all: relaxed: