From my book of Jane: Http://www.jianshu.com/users/85c8826ce087/latest_articles
will take the curd operation of the article as an example, this article only involves the basic routing and Controller > methods, implementation, will continue to explain later.
1. New route
2. Controller
Creating a controller from a terminal
PHP Artisan Make:controller Articlecontroller
Get the Controller class App/http/controllers/articlecontroller
If you want to implement a controller file after creating a folder under App/http/controllers, create a controller class inside, you can use the command:
PHP Aritsan Make:controller Article/articlecontroller
Example of a controller class:
3. (Routing---> Controller) example table for restful control relationships:
Request Method |
Routing Address |
corresponding Controller method |
corresponding route name |
Current Role |
GET |
/article |
Index () |
Route (' Article.index ') |
Show List of articles |
GET |
/article/ |
Create () |
Route (' Article.create ') |
Article new page |
POST |
/article |
Store (Request $request) |
Route (' Article.store ') |
Article Store Operations |
GET |
/article/{id} |
Show ($id) |
Route (' Article.index ') |
Article details show |
GET |
/article/{id}/edit |
Edit ($ID) |
Route (' Article.edit ') |
Article edit page |
Put/patch |
/article/{id}/ |
Update (Request $request, $id) |
Route (' Article.update ') |
Article Update action |
DELETE |
/article/{id} |
Destroy ($ID) |
Route (' Article.destroy ') |
Article Delete action |