Commit 168b450e authored by cygnet's avatar cygnet

changes done to pass the error to validation function as string

parent 86afc0bf
...@@ -198,8 +198,8 @@ class APIController extends Controller ...@@ -198,8 +198,8 @@ class APIController extends Controller
* *
* @return mix * @return mix
*/ */
public function throwValidation($validation) public function throwValidation($message)
{ {
return ['error'=>$validation->errors()]; return ['error'=> $message];
} }
} }
...@@ -62,7 +62,7 @@ class PermissionController extends APIController ...@@ -62,7 +62,7 @@ class PermissionController extends APIController
{ {
$validation = $this->validatePermission($request); $validation = $this->validatePermission($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->create($request->all()); $this->repository->create($request->all());
...@@ -82,7 +82,7 @@ class PermissionController extends APIController ...@@ -82,7 +82,7 @@ class PermissionController extends APIController
$validation = $this->validatePermission($request, $permission->id); $validation = $this->validatePermission($request, $permission->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->update($permission, $request->all()); $this->repository->update($permission, $request->all());
......
...@@ -61,7 +61,7 @@ class RolesController extends APIController ...@@ -61,7 +61,7 @@ class RolesController extends APIController
{ {
$validation = $this->validateRole($request); $validation = $this->validateRole($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->create($request->all()); $this->repository->create($request->all());
...@@ -82,7 +82,7 @@ class RolesController extends APIController ...@@ -82,7 +82,7 @@ class RolesController extends APIController
$validation = $this->validateRole($request); $validation = $this->validateRole($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->update($role, $request->all()); $this->repository->update($role, $request->all());
......
...@@ -62,7 +62,7 @@ class UsersController extends APIController ...@@ -62,7 +62,7 @@ class UsersController extends APIController
$validation = $this->validateUser($request); $validation = $this->validateUser($request);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$this->repository->create($request); $this->repository->create($request);
...@@ -83,7 +83,7 @@ class UsersController extends APIController ...@@ -83,7 +83,7 @@ class UsersController extends APIController
$validation = $this->validateUser($request, 'edit', $user->id); $validation = $this->validateUser($request, 'edit', $user->id);
if ($validation->fails()) { if ($validation->fails()) {
return $this->throwValidation($validation); return $this->throwValidation($validation->messages()->first());
} }
$updatedUser = $this->repository->update($user, $request); $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