53 lines
1,015 B
PHP
53 lines
1,015 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Dto;
|
|
|
|
use App\Models\Faq;
|
|
use Illuminate\Contracts\Routing\UrlRoutable;
|
|
|
|
final readonly class FaqDto implements UrlRoutable
|
|
{
|
|
public function __construct(
|
|
public int $id,
|
|
public string $question,
|
|
public string $answer,
|
|
public int $order,
|
|
) {
|
|
}
|
|
|
|
public static function fromModel(Faq $faq): self
|
|
{
|
|
return new self(
|
|
id: $faq->id,
|
|
question: $faq->question,
|
|
answer: $faq->answer,
|
|
order: $faq->order,
|
|
);
|
|
}
|
|
|
|
#[\Override]
|
|
public function getRouteKey(): mixed
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
#[\Override]
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'id';
|
|
}
|
|
|
|
#[\Override]
|
|
public function resolveRouteBinding($value, $field = null): mixed
|
|
{
|
|
return null;
|
|
}
|
|
|
|
#[\Override]
|
|
public function resolveChildRouteBinding($childType, $value, $field): mixed
|
|
{
|
|
return null;
|
|
}
|
|
}
|