validator() public method

public validator ( array $data ) : mixed
$data array
return mixed
Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param AuthController $auth
  * @internal param Request $request
  * @return Response
  */
 public function store(AuthController $auth)
 {
     $data = Input::all();
     $valid = $auth->validator($data);
     if ($valid->fails()) {
         return redirect()->back()->withInput()->withErrors($valid);
     }
     $user = $auth->create($data);
     Auth::login($user);
     return redirect()->to('admin');
 }
Exemplo n.º 2
0
 /**
  * Register user
  * @param Request $request
  * @return token
  */
 public function postRegister(Request $request)
 {
     $validator = AuthController::validator($request->all());
     if ($validator->fails()) {
         return response()->json(['Email is already registered / Something wrong with input.'], 403);
     }
     //create user
     $user = AuthController::create($request->all());
     //credentials for login
     $credentials = $request->only('email', 'password');
     $token = $this->loginUser($credentials);
     return response()->json(compact('token'));
 }