mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/tickme.git
synced 2026-08-19 12:33:57 +00:00
32 lines
788 B
PHP
32 lines
788 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Accounts\Services;
|
|
|
|
|
|
use App\Classes\Exceptions\InternalServerErrorException;
|
|
use App\Classes\Modules\Accounts\DataTransferObjects\NewPasswordObject;
|
|
use App\Models\User;
|
|
use Illuminate\Database\QueryException;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class ChangesPassword
|
|
{
|
|
|
|
/**
|
|
* @param User $user
|
|
* @param NewPasswordObject $object
|
|
* @return bool
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function execute(User $user, NewPasswordObject $object): bool {
|
|
try {
|
|
|
|
$user->password = Hash::make($object->getPassword());
|
|
return $user->save();
|
|
|
|
} catch (QueryException $exception){
|
|
throw new InternalServerErrorException($exception->getMessage());
|
|
}
|
|
}
|
|
|
|
} |