mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 15:44:45 +02:00

* update composer.lock * run pint * fix phpstan * update migrations (sqlite `dropForeign`) * fix migrations * Reset these back for now * Alphabetize the rules * run `php artisan filament:upgrade` --------- Co-authored-by: Lance Pioch <git@lance.sh>
36 lines
764 B
PHP
36 lines
764 B
PHP
<?php
|
|
|
|
namespace App\Services\Users;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Contracts\Hashing\Hasher;
|
|
use App\Traits\Services\HasUserLevels;
|
|
|
|
class UserUpdateService
|
|
{
|
|
use HasUserLevels;
|
|
|
|
/**
|
|
* UserUpdateService constructor.
|
|
*/
|
|
public function __construct(private Hasher $hasher) {}
|
|
|
|
/**
|
|
* Update the user model instance and return the updated model.
|
|
*
|
|
* @throws \Throwable
|
|
*/
|
|
public function handle(User $user, array $data): User
|
|
{
|
|
if (!empty(array_get($data, 'password'))) {
|
|
$data['password'] = $this->hasher->make($data['password']);
|
|
} else {
|
|
unset($data['password']);
|
|
}
|
|
|
|
$user->forceFill($data)->saveOrFail();
|
|
|
|
return $user->refresh();
|
|
}
|
|
}
|