<?php

namespace App\Http\Resources\Tenant;

use App\Models\EventMember;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/** @mixin EventMember */
class EventMemberResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name ?? $this->user?->full_name ?? $this->email,
            'email' => $this->email,
            'role' => $this->role,
            'status' => $this->status,
            'joined_at' => $this->joined_at,
            'invited_at' => $this->invited_at,
            'avatar_url' => $this->user?->profile_photo_url ?? null,
            'permissions' => $this->permissions,
            'user_id' => $this->user_id,
        ];
    }
}
