Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
05063bc4
Unverified
Commit
05063bc4
authored
Mar 13, 2018
by
Viral Solani
Committed by
GitHub
Mar 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #172 from indranshastri/develop
Resolve Validation errors on APIs
parents
9852dc1d
168b450e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
APIController.php
app/Http/Controllers/Api/V1/APIController.php
+2
-2
PermissionController.php
app/Http/Controllers/Api/V1/PermissionController.php
+2
-2
RolesController.php
app/Http/Controllers/Api/V1/RolesController.php
+2
-2
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+2
-2
No files found.
app/Http/Controllers/Api/V1/APIController.php
View file @
05063bc4
...
@@ -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
];
}
}
}
}
app/Http/Controllers/Api/V1/PermissionController.php
View file @
05063bc4
...
@@ -61,7 +61,7 @@ class PermissionController extends APIController
...
@@ -61,7 +61,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
());
...
@@ -81,7 +81,7 @@ class PermissionController extends APIController
...
@@ -81,7 +81,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
());
...
...
app/Http/Controllers/Api/V1/RolesController.php
View file @
05063bc4
...
@@ -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
());
...
...
app/Http/Controllers/Api/V1/UsersController.php
View file @
05063bc4
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment