adrema/app/Form/Resources/FormtemplateResource.php

70 lines
1.8 KiB
PHP
Raw Normal View History

2023-12-22 20:40:24 +01:00
<?php
namespace App\Form\Resources;
2024-02-16 14:18:16 +01:00
use App\Form\Enums\NamiType;
2024-03-15 00:39:17 +01:00
use App\Form\Enums\SpecialType;
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-31 14:29:50 +01:00
use App\Group;
use App\Lib\Editor\EditorData;
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()]),
2024-02-19 03:01:18 +01:00
'destroy' => route('formtemplate.destroy', ['formtemplate' => $this->getModel()]),
2023-12-25 22:51:07 +01:00
]
];
2023-12-22 20:40:24 +01:00
}
/**
* @return array<string, mixed>
*/
public static function meta(): array
{
return [
2023-12-31 14:29:50 +01:00
'base_url' => url(''),
'groups' => Group::forSelect(),
2023-12-26 00:44:49 +01:00
'fields' => Field::asMeta(),
2024-02-19 03:01:18 +01:00
'namiTypes' => NamiType::forSelect(),
2024-03-15 00:39:17 +01:00
'specialTypes' => SpecialType::forSelect(),
2023-12-22 20:40:24 +01:00
'links' => [
'store' => route('formtemplate.store'),
2024-01-01 18:29:33 +01:00
'form_index' => route('form.index'),
2023-12-22 20:40:24 +01:00
],
'default' => [
'name' => '',
'mail_top' => EditorData::default(),
'mail_bottom' => EditorData::default(),
2023-12-22 20:40:24 +01:00
'config' => [
'sections' => [],
]
],
'section_default' => [
2023-12-25 19:35:00 +01:00
'name' => '',
'intro' => '',
2023-12-22 20:40:24 +01:00
'fields' => [],
]
];
}
}