36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\NotificationAction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class NotificationActionResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'project_id' => $this->project_id,
|
|
'name' => $this->name,
|
|
'enabled' => $this->enabled,
|
|
'event_type' => $this->event_type->value,
|
|
'event_type_label' => $this->event_type->label(),
|
|
'channel' => $this->channel->value,
|
|
'channel_label' => $this->channel->label(),
|
|
'channel_configuration' => $this->channel_configuration ?? [],
|
|
'filters' => $this->filters ?? [],
|
|
'has_delivery_url' => $this->resource instanceof NotificationAction && filled($this->delivery_url),
|
|
'message_template' => $this->message_template,
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|