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