update deploy
This commit is contained in:
57
app/DTOs/AnnouncementData.php
Normal file
57
app/DTOs/AnnouncementData.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
class AnnouncementData
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $slug,
|
||||
public readonly string $title,
|
||||
public readonly string $category,
|
||||
public readonly string $excerpt,
|
||||
public readonly string $content,
|
||||
public readonly ?string $image = null,
|
||||
public readonly bool $isFeatured = false,
|
||||
public readonly ?string $metaTitle = null,
|
||||
public readonly ?string $metaDescription = null,
|
||||
public readonly ?string $publishedAt = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
slug: $data['slug'],
|
||||
title: $data['title'],
|
||||
category: $data['category'],
|
||||
excerpt: $data['excerpt'],
|
||||
content: $data['content'],
|
||||
image: $data['image'] ?? null,
|
||||
isFeatured: $data['is_featured'] ?? false,
|
||||
metaTitle: $data['meta_title'] ?? null,
|
||||
metaDescription: $data['meta_description'] ?? null,
|
||||
publishedAt: $data['published_at'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'slug' => $this->slug,
|
||||
'title' => $this->title,
|
||||
'category' => $this->category,
|
||||
'excerpt' => $this->excerpt,
|
||||
'content' => $this->content,
|
||||
'image' => $this->image,
|
||||
'is_featured' => $this->isFeatured,
|
||||
'meta_title' => $this->metaTitle,
|
||||
'meta_description' => $this->metaDescription,
|
||||
'published_at' => $this->publishedAt,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user