<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class AjoGroupResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'contribution_type' => $this->contribution_type,
            'contribution_amount_minor' => $this->contribution_amount,
            'currency' => $this->whenLoaded('business', fn () => $this->business->currency),
            'maximum_members' => $this->maximum_members,
            'members_count' => $this->whenCounted('members'),
            'start_date' => $this->start_date?->toDateString(),
            'end_date' => $this->end_date?->toDateString(),
            'status' => $this->status->value,
        ];
    }
}
