api code global jain

This commit is contained in:
Abhishek Mali
2025-11-05 10:37:10 +05:30
commit 52fe7e2bec
2834 changed files with 1784903 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Repositories\Backend\Auth;
use App\Models\User;
use App\Services\BaseService;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
class ChangePasswordService extends BaseService
{
/**
* Associated Repository Model.
*/
const MODEL = User::class;
public function updatePassword(array $request): array
{
$response = [
'status' => static::STATUS_FALSE,
'message' => 'Something went wrong,'
];
try {
$object = loggedInUser();
if (Hash::check($request['current_password'], $object->password)) {
$object->password = Hash::make($request['new_password']);
if ($object->save()) {
$response['status'] = static::STATUS_TRUE;
$response['message'] = trans('account_setting.validate.change_password.message_1');
}
} else {
$response['message'] = trans('account_setting.validate.change_password.message_2');
}
} catch (\Exception $ex) {
Log::error($ex);
}
return $response;
}
}