mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
changing the way validation works
This commit is contained in:
parent
98793fd74a
commit
5462e4276a
@ -34,8 +34,26 @@ class AccountApiController extends BaseAPIController
|
||||
$this->accountRepo = $accountRepo;
|
||||
}
|
||||
|
||||
public function register(RegisterRequest $request)
|
||||
public function register(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'email' => 'required|unique:users',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
foreach($validator->messages->all() as $message)
|
||||
{
|
||||
return $this->errorResponse(['message'=>$message]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
||||
$user = $account->users()->first();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user