adrema/app/Mailgateway/Resources/MailgatewayResource.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2023-06-01 15:02:35 +02:00
<?php
namespace App\Mailgateway\Resources;
use App\Lib\HasMeta;
2024-10-24 23:17:23 +02:00
use Modules\Mailgateway\Models\Mailgateway;
2023-06-01 15:02:35 +02:00
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Mailgateway
2024-10-20 18:29:03 +02:00
* @deprecated
2023-06-01 15:02:35 +02:00
*/
class MailgatewayResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*
2023-06-15 00:33:13 +02:00
* @return array<string, mixed>
2023-06-01 15:02:35 +02:00
*/
public function toArray($request)
{
return [
'name' => $this->name,
'domain' => $this->domain,
'type_human' => $this->type::name(),
'works' => $this->type->works(),
2023-06-08 00:14:55 +02:00
'id' => $this->id,
'links' => [
'update' => route('mailgateway.update', ['mailgateway' => $this->getModel()]),
],
2023-06-01 15:02:35 +02:00
];
}
2023-06-15 00:33:13 +02:00
/**
* @return array<string, mixed>
*/
2023-06-01 15:02:35 +02:00
public static function meta(): array
{
return [
'links' => [
2023-06-07 21:40:58 +02:00
'store' => route('mailgateway.store'),
2023-06-01 15:02:35 +02:00
],
2023-06-01 15:45:02 +02:00
'types' => app('mail-gateways')->map(fn ($gateway) => [
'id' => $gateway,
'name' => $gateway::name(),
2023-06-07 22:52:02 +02:00
'fields' => $gateway::presentFields('storeValidator'),
2023-06-01 16:50:50 +02:00
'defaults' => (object) $gateway::defaults(),
])->prepend([
'id' => null,
'name' => '-- kein --',
'fields' => [],
'defaults' => (object) [],
2023-06-01 15:45:02 +02:00
]),
'default' => [
'domain' => '',
'name' => '',
'type' => [
'params' => [],
2023-06-01 16:50:50 +02:00
'cls' => null,
2023-06-01 15:45:02 +02:00
],
],
2023-06-01 15:02:35 +02:00
];
}
}