Skip to content

Commit 129614e

Browse files
authored
Update README.md
1 parent 5a2fdf5 commit 129614e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,46 @@ Specifying the controller methods with get/post/any prefixes improves readabilit
1414

1515
Does your router file not fit the screen and you have to scroll to see all routes? Have you split your routes in separate router files, and included these in one router files? Do you not feel comfortable removing routes, as these might be used somewhere? Do you use names to "name" your routes? Then its time to think outside the box and go advanced.
1616

17+
## How it works ##
18+
19+
The advanced route allows you to easily define a single route to handle every action in a controller class. First, define the route using the AdvancedRoute::controller method. The controller method accepts two arguments. The first is the base URI the controller handles, while the second is the class name of the controller. Next, just add methods to your controller. The method names should begin with the HTTP verb they respond to followed by the title case version of the URI.
20+
21+
```php
22+
<?php
23+
24+
namespace App\Http\Controllers;
25+
26+
class UserController extends Controller {
27+
/**
28+
* Responds to any (GET,POST, etc) request to /users
29+
*/
30+
public function anyIndex() {
31+
//
32+
}
33+
34+
/**
35+
* Responds to requests to GET /users/show/1
36+
*/
37+
public function getShow($id) {
38+
//
39+
}
40+
41+
/**
42+
* Responds to requests to GET /users/admin-profile
43+
*/
44+
public function getAdminProfile() {
45+
//
46+
}
47+
48+
/**
49+
* Responds to requests to POST /users/profile
50+
*/
51+
public function postProfile() {
52+
//
53+
}
54+
}
55+
```
56+
1757
## Installation ##
1858

1959
### a) via composer (recommended) ###

0 commit comments

Comments
 (0)