In routes. php defines a RESTful {code ...} in ComController. php defines the following method {code ...} $ id will report an error. Is there any good way to define a route corresponding to the method under a controller that no longer needs to be defined on the route? {generation... in routes. php defines a RESTful
Route::resource('com','ComController');
InComController.php
The following method is defined in
public function index() { return "index"; } public function show() { return "show"; } public function edit($id) { return "edit".$id; } public function del($id) { return "del".$id; }
$id
An error is reported.
Is there any good way to define a route corresponding to a controller?
The following method of the controller does not need to be defined on the route.
Route::controllers([ 'com' => 'ComController',]);
How to use this route$id
What about
RouteRESTful
Method andcontrollers
What is the difference?
Please give me some advice.
Reply content:
In routes. php, a RESTful
Route::resource('com','ComController');
InComController.php
The following method is defined in
public function index() { return "index"; } public function show() { return "show"; } public function edit($id) { return "edit".$id; } public function del($id) { return "del".$id; }
$id
An error is reported.
Is there any good way to define a route corresponding to a controller?
The following method of the controller does not need to be defined on the route.
Route::controllers([ 'com' => 'ComController',]);
How to use this route$id
What about
RouteRESTful
Method andcontrollers
What is the difference?
Please give me some advice.
Your need should be:
Http://laravel.com/docs/5.0/controllers#implicit-controllers
Routes. php
php
Route::controller('users', 'UserController');
UserController. php
php
// GET http://domain/users/indexpublic function getIndex() {}// POST http://domain/users/profile/3public function postProfile($id) {}// DELETE http://domain/users/user/3public function deleteUser($id) {}
Verb path behavior route name
GET/photo index photo. index
GET/photo/create photo. create
POST/photo save photo. store
GET/photo/{photo} shows photo. show
GET/photo/{photo}/edit photo. edit
PUT/PATCH/photo/{photo} update photo. update
DELETE/photo/{photo} DELETE photo. destroy
You have read the document, and it has set a good path for you.
For example, index
Restfull should be: http: // {domain}/photo, instead of: http: // {domain}/photo/index