adrema/app/Form/Actions/ParticipantIndexAction.php

26 lines
680 B
PHP
Raw Normal View History

2024-02-08 21:04:00 +01:00
<?php
namespace App\Form\Actions;
use App\Form\Models\Form;
use App\Form\Resources\ParticipantResource;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Pagination\LengthAwarePaginator;
use Lorisleiva\Actions\Concerns\AsAction;
class ParticipantIndexAction
{
use AsAction;
public function handle(Form $form): LengthAwarePaginator
{
return $form->participants()->with('form')->paginate(15);
}
2024-02-08 23:09:51 +01:00
public function asController(Form $form): AnonymousResourceCollection
2024-02-08 21:04:00 +01:00
{
return ParticipantResource::collection($this->handle($form))
->additional(['meta' => ParticipantResource::meta($form)]);
}
}