1
0
Fork 0

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:
Henrik Hautakoski 2021-07-22 18:50:06 +02:00
parent dccd04fe7e
commit 52f565f04b

View file

@ -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();