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