update deploy
This commit is contained in:
44
app/DTOs/FaqData.php
Normal file
44
app/DTOs/FaqData.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
use App\Enums\FaqCategory;
|
||||
|
||||
final readonly class FaqData
|
||||
{
|
||||
public function __construct(
|
||||
public string $question,
|
||||
public string $answer,
|
||||
public FaqCategory $category,
|
||||
public int $orderIndex = 0,
|
||||
public bool $isActive = true,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
return new self(
|
||||
question: $data['question'],
|
||||
answer: $data['answer'],
|
||||
category: FaqCategory::from($data['category']),
|
||||
orderIndex: $data['order_index'] ?? 0,
|
||||
isActive: $data['is_active'] ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'question' => $this->question,
|
||||
'answer' => $this->answer,
|
||||
'category' => $this->category->value,
|
||||
'order_index' => $this->orderIndex,
|
||||
'is_active' => $this->isActive,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user