Path: blob/1.0-develop/app/Services/Users/UserUpdateService.php
10277 views
<?php12namespace Pterodactyl\Services\Users;34use Pterodactyl\Models\User;5use Illuminate\Contracts\Hashing\Hasher;6use Pterodactyl\Traits\Services\HasUserLevels;78class UserUpdateService9{10use HasUserLevels;1112/**13* UserUpdateService constructor.14*/15public function __construct(private Hasher $hasher)16{17}1819/**20* Update the user model instance and return the updated model.21*22* @throws \Throwable23*/24public function handle(User $user, array $data): User25{26if (!empty(array_get($data, 'password'))) {27$data['password'] = $this->hasher->make($data['password']);28} else {29unset($data['password']);30}3132$user->forceFill($data)->saveOrFail();3334return $user->refresh();35}36}373839