<?php

namespace App\Member\Actions;

use App\Member\Member;
use App\Member\MemberResource;
use Illuminate\Http\JsonResponse;
use Lorisleiva\Actions\Concerns\AsAction;

class MemberShowAction
{
    use AsAction;

    public function asController(Member $member): JsonResponse
    {
        return response()->json([
            'data' => new MemberResource($member
                ->load('memberships')
                ->load('invoicePositions.invoice')
                ->load('nationality')
                ->load('region')
                ->load('subscription')
                ->load('courses.course')),
            'meta' => MemberResource::meta(),
        ]);
    }
}
