Unverified Commit 05063bc4 authored by Viral Solani's avatar Viral Solani Committed by GitHub

Merge pull request #172 from indranshastri/develop

Resolve Validation errors on APIs
parents 9852dc1d 168b450e
......@@ -198,8 +198,8 @@ class APIController extends Controller
*
* @return mix
*/
public function throwValidation($validation)
public function throwValidation($message)
{
return ['error'=>$validation->errors()];
return ['error'=> $message];
}
}
......@@ -61,7 +61,7 @@ class PermissionController extends APIController
{
$validation = $this->validatePermission($request);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
......@@ -81,7 +81,7 @@ class PermissionController extends APIController
$validation = $this->validatePermission($request, $permission->id);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($permission, $request->all());
......
......@@ -61,7 +61,7 @@ class RolesController extends APIController
{
$validation = $this->validateRole($request);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request->all());
......@@ -82,7 +82,7 @@ class RolesController extends APIController
$validation = $this->validateRole($request);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$this->repository->update($role, $request->all());
......
......@@ -62,7 +62,7 @@ class UsersController extends APIController
$validation = $this->validateUser($request);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$this->repository->create($request);
......@@ -83,7 +83,7 @@ class UsersController extends APIController
$validation = $this->validateUser($request, 'edit', $user->id);
if ($validation->fails()) {
return $this->throwValidation($validation);
return $this->throwValidation($validation->messages()->first());
}
$updatedUser = $this->repository->update($user, $request);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment