app/Http/Controllers/ProfileController.php: in update() use Model::fill()
This is more generic as one only needs to add validated fields to Request object. and they will be saved automatically.
This commit is contained in:
parent
dccd04fe7e
commit
52f565f04b
1 changed files with 2 additions and 3 deletions
|
|
@ -25,11 +25,10 @@ class ProfileController extends Controller
|
|||
|
||||
public function update(UserRequest $request)
|
||||
{
|
||||
$data = $request->validated();
|
||||
$data = collect($request->validated());
|
||||
|
||||
$user = $request->user();
|
||||
$user->username = $data['username'];
|
||||
$user->character_id = $data['character_id'];
|
||||
$user->fill($data->except('password')->toArray());
|
||||
$user->password = Hash::make($data['password']);
|
||||
$user->save();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue