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
820eb477
Commit
820eb477
authored
Mar 13, 2018
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve error of update user API
parent
3090ca17
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+4
-2
UserResource.php
app/Http/Resources/UserResource.php
+3
-0
UserRepository.php
app/Repositories/Backend/Access/User/UserRepository.php
+2
-2
No files found.
app/Http/Controllers/Api/V1/UsersController.php
View file @
820eb477
...
...
@@ -86,9 +86,11 @@ class UsersController extends APIController
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$
updatedUser
=
$
this
->
repository
->
update
(
$user
,
$request
);
$this
->
repository
->
update
(
$user
,
$request
);
return
new
UserResource
(
$updatedUser
);
$user
=
User
::
findOrfail
(
$user
->
id
);
return
new
UserResource
(
$user
);
}
/**
...
...
app/Http/Resources/UserResource.php
View file @
820eb477
...
...
@@ -20,8 +20,11 @@ class UserResource extends Resource
'first_name'
=>
$this
->
first_name
,
'last_name'
=>
$this
->
last_name
,
'email'
=>
$this
->
email
,
'picture'
=>
$this
->
getPicture
(),
'confirmed'
=>
$this
->
confirmed
,
'role'
=>
optional
(
$this
->
roles
()
->
first
())
->
name
,
'permissions'
=>
$this
->
permissions
()
->
get
(),
'status'
=>
$this
->
status
,
'registered_at'
=>
$this
->
created_at
->
toIso8601String
(),
'last_updated_at'
=>
$this
->
updated_at
->
toIso8601String
(),
];
...
...
app/Repositories/Backend/Access/User/UserRepository.php
View file @
820eb477
...
...
@@ -144,7 +144,7 @@ class UserRepository extends BaseRepository
if
(
$user
->
update
(
$data
))
{
$user
->
status
=
isset
(
$data
[
'status'
])
?
1
:
0
;
$user
->
confirmed
=
isset
(
$data
[
'confirmed'
])
?
1
:
0
;
$u
pdatedUser
=
tap
(
$user
)
->
save
();
$u
ser
->
save
();
$this
->
checkUserRolesCount
(
$roles
);
$this
->
flushRoles
(
$roles
,
$user
);
...
...
@@ -152,7 +152,7 @@ class UserRepository extends BaseRepository
$this
->
flushPermissions
(
$permissions
,
$user
);
event
(
new
UserUpdated
(
$user
));
return
$updatedUser
;
return
true
;
}
throw
new
GeneralException
(
trans
(
'exceptions.backend.access.users.update_error'
));
...
...
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