<?php

namespace App\Http\Controllers\Api\Advisories;

use App\Http\Controllers\Controller;
use App\Models\Advisories\AdvisoryMember;
use App\Transformers\Advisories\AdvisoryMemberTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class AdvisoryMembersController extends Controller {
    protected AdvisoryMember $model;

    public function __construct(AdvisoryMember $model) {
        $this->model = $model;
    }

    public function index(Request $request): JsonResponse {
        $query = $this->model->query();
        $paginator = $query->paginate(config('app.pagination_limit'));
        return fractal($paginator, new AdvisoryMemberTransformer())->respond();
    }

    public function show(Request $request, $id): JsonResponse {
        $model = $this->model->byUuid($id)->firstOrFail();
        return fractal($model, new AdvisoryMemberTransformer())->respond();
    }

    public function store(Request $request): void {
    }

    public function update(Request $request, $uuid): void {
    }

    public function destroy(Request $request, $uuid): JsonResponse {
        $model = $this->model->byUuid($uuid)->firstOrFail();
        $model->delete();
        return response()->json(null, 204);
    }


}
