Add notification action foundation

This commit is contained in:
Eric Peters
2026-04-20 21:59:57 +02:00
parent 8df9622f1b
commit e4762f8e32
22 changed files with 1047 additions and 0 deletions
@@ -0,0 +1,34 @@
<?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 ?? [],
'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(),
];
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class NotificationDeliveryLogResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'notification_action_id' => $this->notification_action_id,
'event_type' => $this->event_type->value,
'event_type_label' => $this->event_type->label(),
'channel' => $this->channel->value,
'channel_label' => $this->channel->label(),
'delivery_status' => $this->delivery_status->value,
'delivery_status_label' => $this->delivery_status->label(),
'attempt_count' => $this->attempt_count,
'http_status' => $this->http_status,
'response_excerpt' => $this->response_excerpt,
'error_excerpt' => $this->error_excerpt,
'payload_metadata' => $this->payload_metadata,
'last_attempted_at' => $this->last_attempted_at?->toISOString(),
'delivered_at' => $this->delivered_at?->toISOString(),
'created_at' => $this->created_at?->toISOString(),
'updated_at' => $this->updated_at?->toISOString(),
];
}
}