DONE: fix error on pagination where it cannot redirect to next pages, add onboarding_completed_at for new registered user, move dashboard page design into modules folder
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->timestamp('onboarding_completed_at')->nullable()->after('birth_place');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('onboarding_completed_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -127,6 +127,17 @@ class UserController extends BaseCrudController
|
||||
]);
|
||||
}
|
||||
|
||||
public function completeOnboarding(Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->userService->completeOnboarding($request->user());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => new UserResource($user),
|
||||
'message' => 'Onboarding completed.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
@@ -35,6 +35,7 @@ Route::middleware(['auth:sanctum', 'single.session'])->prefix('v1')->group(funct
|
||||
|
||||
// User profile management routes
|
||||
Route::post('/profile', [UserController::class, 'updateProfile']);
|
||||
Route::post('/profile/onboarding/complete', [UserController::class, 'completeOnboarding']);
|
||||
Route::put('/profile/password', [UserController::class, 'updatePassword']);
|
||||
Route::get('/profile/digital-card', [MemberDigitalCardController::class, 'download'])
|
||||
->name('profile.digital-card.download');
|
||||
|
||||
@@ -121,6 +121,17 @@ class UserService
|
||||
/**
|
||||
* @return array{}|array{error: string}
|
||||
*/
|
||||
public function completeOnboarding(User $user): User
|
||||
{
|
||||
if ($user->onboarding_completed_at === null) {
|
||||
$user->update(['onboarding_completed_at' => now()]);
|
||||
}
|
||||
|
||||
$user->load(['roles.permissions']);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function updatePassword(User $user, string $currentPassword, string $newPassword): array
|
||||
{
|
||||
if (! Hash::check($currentPassword, $user->password)) {
|
||||
|
||||
Reference in New Issue
Block a user