问:如何从其他控制器重用Auth的 ResigsterController 验证规则,而无需获取整个 RegisterController 类?
以下是规则:
...
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
}