Skip to content

Commit

Permalink
Id DOC Media Added
Browse files Browse the repository at this point in the history
  • Loading branch information
hafijul233 committed Oct 28, 2024
1 parent 73ab097 commit b6f25b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'update_password' => 'New password updated successfully.',
'update_pin' => 'New pin updated successfully.',
'update_photo' => 'New profile photo updated successfully.',
'user_profile_update' => 'User :field updated successfully.',
'reset' => [
'success' => 'Your account password reset successful.',
'temporary_password' => 'We have send you a temporary password. Please log into you account with credentials.',
Expand Down
10 changes: 5 additions & 5 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Fintech\RestApi\Http\Controllers\Auth\RolePermissionController;
use Fintech\RestApi\Http\Controllers\Auth\SettingController;
use Fintech\RestApi\Http\Controllers\Auth\UserController;
use Fintech\RestApi\Http\Controllers\Auth\ProfileController;
use Fintech\RestApi\Http\Controllers\Auth\VerifyIdDocumentController;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;
Expand Down Expand Up @@ -74,14 +75,15 @@

Route::middleware(config('fintech.auth.middleware'))->group(function () {

Route::post('update-password', [PasswordController::class, 'update'])
Route::post('update-password', [PasswordController::class, 'updatePassword'])
->name('update-password');

Route::post('update-pin', [PasswordController::class, 'updatePin'])
->name('update-pin');

Route::post('update-photo', [UserController::class, 'photo'])
->name('update-photo');
Route::get('profile', [ProfileController::class, 'show'])->name('profile.show');

Route::patch('profile', [ProfileController::class, 'update'])->name('profile.update');

Route::apiResource('users', UserController::class);
// Route::post('users/{user}/restore', [UserController::class, 'restore'])->name('users.restore');
Expand All @@ -94,10 +96,8 @@
->whereIn('field', ['pin', 'password', 'both']);

Route::apiResource('roles', RoleController::class);
// Route::post('roles/{role}/restore', [RoleController::class, 'restore'])->name('roles.restore');

Route::apiResource('permissions', PermissionController::class);
// Route::post('permissions/{permission}/restore', [PermissionController::class, 'restore'])->name('permissions.restore');

Route::apiResource('role-permissions', RolePermissionController::class)
->only(['show', 'update']);
Expand Down
2 changes: 1 addition & 1 deletion src/Middlewares/LastLoggedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function terminate(Request $request, $response): void
$user = \Illuminate\Support\Facades\Auth::user();

if ($user) {
Auth::user()->updateRaw($user->getKey(), ['logged_in_at' => now()]);
Auth::user()->update($user->getKey(), ['logged_in_at' => now()]);
}
}
}
2 changes: 1 addition & 1 deletion src/Middlewares/LastLoggedOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle(Request $request, Closure $next)
$user = \Illuminate\Support\Facades\Auth::user();

if ($user) {
Auth::user()->updateRaw($user->getKey(), ['logged_out_at' => now()]);
Auth::user()->update($user->getKey(), ['logged_out_at' => now()]);
}

return $next($request);
Expand Down
14 changes: 10 additions & 4 deletions src/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ private function formatDataFromInput($inputs, bool $forCreate = false)
return $data;
}

public function updateRaw($id, array $inputs = [])
/**
* @throws \ErrorException
*/
public function update($id, array $inputs = []): ?BaseModel
{
DB::beginTransaction();

Expand All @@ -154,11 +157,14 @@ public function updateRaw($id, array $inputs = [])

} catch (Exception $exception) {
DB::rollBack();
throw new PDOException($exception->getMessage(), 0, $exception);
throw new \ErrorException($exception->getMessage(), 0, $exception);
}
}

public function update($id, array $inputs = [])
/**
* @throws \ErrorException
*/
public function updateFromAdmin($id, array $inputs = []): ?BaseModel
{
DB::beginTransaction();

Expand All @@ -176,7 +182,7 @@ public function update($id, array $inputs = [])

} catch (Exception $exception) {
DB::rollBack();
throw new PDOException($exception->getMessage(), 0, $exception);
throw new \ErrorException($exception->getMessage(), 0, $exception);
}
}

Expand Down

0 comments on commit b6f25b0

Please sign in to comment.