Restructures account/profile pages to match Vuexy's account-settings tab pattern (Account, Security, Notifications) and fixes the MFA enforcement banner that stayed visible after successful setup. Backend: - Add phone column to users table with migration - Add PUT /me/profile endpoint for profile updates - Create UpdateProfileRequest form request - Update MeResource to include phone field Organizer app: - Rewrite account-settings as tabbed page (VTabs pill style + VWindow) - Create AccountTab: avatar, profile form, email change, danger zone - Create SecurityTab: password change, MFA method cards, backup codes, trusted devices, disable MFA danger zone - Create NotificationsTab: placeholder with disabled toggles - Fix MFA banner: set authStore.mfaSetupRequired = false on setup complete - Update router guard to redirect to ?tab=security for MFA enforcement - Update UserProfile menu links to use tab query params Portal: - Restructure profiel.vue with VTabs (Mijn profiel + Beveiliging) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
2.3 KiB
PHP
59 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use App\Models\Person;
|
|
use App\Services\MfaService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class MeResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'first_name' => $this->first_name,
|
|
'last_name' => $this->last_name,
|
|
'full_name' => $this->full_name,
|
|
'date_of_birth' => $this->date_of_birth?->toDateString(),
|
|
'email' => $this->email,
|
|
'phone' => $this->phone,
|
|
'timezone' => $this->timezone,
|
|
'locale' => $this->locale,
|
|
'avatar' => $this->avatar,
|
|
'email_verified_at' => $this->email_verified_at?->toIso8601String(),
|
|
'organisations' => $this->whenLoaded('organisations', fn () =>
|
|
$this->organisations->map(fn ($org) => [
|
|
'id' => $org->id,
|
|
'name' => $org->name,
|
|
'slug' => $org->slug,
|
|
'role' => $org->pivot->role,
|
|
])
|
|
),
|
|
'app_roles' => $this->getRoleNames()->values()->all(),
|
|
'permissions' => $this->getAllPermissions()->pluck('name')->values()->all(),
|
|
'portal_events' => $this->whenLoaded('persons', fn () =>
|
|
$this->persons->map(fn (Person $person) => [
|
|
'event_id' => $person->event_id,
|
|
'event_name' => $person->event->name,
|
|
'event_slug' => $person->event->slug,
|
|
'organisation_name' => $person->event->organisation->name,
|
|
'person_id' => $person->id,
|
|
'person_status' => $person->status,
|
|
'start_date' => $person->event->start_date?->toDateString(),
|
|
'end_date' => $person->event->end_date?->toDateString(),
|
|
])
|
|
),
|
|
'mfa' => [
|
|
'enabled' => $this->mfa_enabled,
|
|
'method' => $this->mfa_method,
|
|
'confirmed_at' => $this->mfa_confirmed_at?->toIso8601String(),
|
|
'setup_required' => app(MfaService::class)->isMfaRequired($this->resource) && ! $this->mfa_enabled,
|
|
],
|
|
];
|
|
}
|
|
}
|