adrema/app/Form/Resources/FormtemplateResource.php

58 lines
1.2 KiB
PHP
Raw Normal View History

2023-12-22 20:40:24 +01:00
<?php
namespace App\Form\Resources;
2023-12-26 00:44:49 +01:00
use App\Form\Fields\Field;
2023-12-26 20:06:57 +01:00
use App\Form\Models\Formtemplate;
2023-12-22 20:40:24 +01:00
use App\Lib\HasMeta;
use Illuminate\Http\Resources\Json\JsonResource;
2023-12-26 20:06:57 +01:00
/**
* @mixin Formtemplate
*/
2023-12-22 20:40:24 +01:00
class FormtemplateResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array<string, mixed>
*/
public function toArray($request)
{
2023-12-25 22:51:07 +01:00
return [
...parent::toArray($request),
'links' => [
'update' => route('formtemplate.update', ['formtemplate' => $this->getModel()]),
]
];
2023-12-22 20:40:24 +01:00
}
/**
* @return array<string, mixed>
*/
public static function meta(): array
{
return [
2023-12-26 00:44:49 +01:00
'fields' => Field::asMeta(),
2023-12-22 20:40:24 +01:00
'links' => [
'store' => route('formtemplate.store'),
],
'default' => [
'name' => '',
'config' => [
'sections' => [],
]
],
'section_default' => [
2023-12-25 19:35:00 +01:00
'name' => '',
'intro' => '',
2023-12-22 20:40:24 +01:00
'fields' => [],
]
];
}
}