在Laravel 5.2中,我可以通过创建一个Request类(request
)来验证php artisan make:request UserStoreRequest
然后在我的控制器中,我可以做到:
public function store(UserStoreRequest $request)
{
//logic
}
如果我UserStoreRequest
中的一条规则失败,我收到了类似的回复:
{
"error": {
"email": [
"The email has already been taken."
]
}
}
但是如果我在Laravel 5.3
收到完全相同的话:
NotFoundHttpException in RouteCollection.php line 161:
它看起来像是web.php
而不是api.php
。
同样在Laravel 5.3
UserStoreRequest
extends FormRequest
(use Illuminate\Foundation\Http\FormRequest;)
在Laravel 5.2
UserStoreRequest
extends Request
(use App\Http\Requests\Request;)
我怎样才能让它再次运作!!!
(我已经通过全新安装Laravel 5.3
)
途径:
| POST | api/login | | App\Http\Controllers\Auth\AuthController@login | api |
| | GET|HEAD | api/register/{user}/verify/{ConformationCode} | | App\Http\Controllers\Auth\AdminController@confirm | api |
| | GET|HEAD | api/user | user.index | App\Http\Controllers\User\UserController@index | api,active |
| | POST | api/user | user.store | App\Http\Controllers\User\UserController@store | api,active |
| | GET|HEAD | api/user/create | user.create | App\Http\Controllers\User\UserController@create | api,active |
| | GET|HEAD | api/user/{user} | user.show | App\Http\Controllers\User\UserController@show | api,active |
| | PUT|PATCH | api/user/{user} | user.update | App\Http\Controllers\User\UserController@update | api,active |
| | DELETE | api/user/{user} | user.destroy | App\Http\Controllers\User\UserController@destroy | api,active |
| | GET|HEAD | api/user/{user}/edit | user.edit | App\Http\Controllers\User\UserController@edit | api,active