re-working validation

This commit is contained in:
David Bomba 2016-03-13 23:49:51 +11:00
parent ba3ca0dffc
commit 22f683152d

View File

@ -19,7 +19,6 @@ class RegisterRequest extends Request
public function __construct(InputRequest $req) public function __construct(InputRequest $req)
{ {
$this->req = $req; $this->req = $req;
} }
@ -48,42 +47,21 @@ class RegisterRequest extends Request
public function response(array $errors) public function response(array $errors)
{ {
/* If the user is not validating from a mobile app - pass through parent::response*/
Log::info($this->req->api_secret);
Log::info($this->req->email);
if(!isset($this->req->api_secret)) if(!isset($this->req->api_secret))
return parent::response($errors); return parent::response($errors);
Log::info($errors); /* If the user is validating from a mobile app - pass through first error string and return error*/
foreach($errors as $error) {
foreach ($error as $key => $value) {
foreach($errors as $err) { $message['error'] = ['message'=>$value];
foreach ($err as $key => $value) { $message = json_encode($error, JSON_PRETTY_PRINT);
Log::info($err);
Log::info($key);
Log::info($value);
$error['error'] = ['message'=>$value];
$error = json_encode($error, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders(); $headers = Utils::getApiHeaders();
return Response::make($error, 400, $headers); return Response::make($message, 400, $headers);
} }
} }
} }
public function setRequest($request)
{
$this->request = $request;
}
public function getRequest()
{
return $this->request;
}
} }