adrema/app/Form/Actions/FormIndexAction.php

31 lines
616 B
PHP
Raw Normal View History

2023-12-31 22:35:13 +01:00
<?php
namespace App\Form\Actions;
use App\Form\Models\Form;
use App\Form\Resources\FormResource;
use Illuminate\Pagination\LengthAwarePaginator;
use Inertia\Inertia;
use Inertia\Response;
use Lorisleiva\Actions\Concerns\AsAction;
class FormIndexAction
{
use AsAction;
/**
* @return LengthAwarePaginator<Form>
*/
public function handle(): LengthAwarePaginator
{
return Form::paginate(15);
}
public function asController(): Response
{
return Inertia::render('form/Index', [
'data' => FormResource::collection($this->handle()),
]);
}
}