問:如何重新從另一個控制器驗證的ResigsterController驗證規則,而不必抓住整個RegisterController類?
下面是規則:重用laravel驗證規則
...
protected function validator(array $data)
{
return Validator::make($data, [
'fname' => 'required|string|max:255',
'lname' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'tos' => 'boolean|accepted',
]);
}
...
中的其他控制器:
應用程序\ HTTP \控制器\ UserController.php
public function update(Request $request, User $user)
{
//I need to validate $request with the rules from
//ControllersAuth\RegisterController.php
}
你可以創建一個表單請求驗證和使用時,你需要... –
檢查我的答案,如果你想與特質,謝謝 –