Build Laravel 13 ticket assistant with Docker, Livewire admin, and helpdesk scraper command
This commit is contained in:
35
app/DTOs/ArticleCandidateDTO.php
Normal file
35
app/DTOs/ArticleCandidateDTO.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs;
|
||||
|
||||
use App\Models\Article;
|
||||
|
||||
class ArticleCandidateDTO
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $articleId,
|
||||
public readonly string $title,
|
||||
public readonly string $content,
|
||||
public readonly float $distance
|
||||
) {}
|
||||
|
||||
public static function fromArticle(Article $article, float $distance): self
|
||||
{
|
||||
return new self(
|
||||
articleId: $article->id,
|
||||
title: $article->title,
|
||||
content: $article->content,
|
||||
distance: $distance
|
||||
);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'article_id' => $this->articleId,
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
'distance' => $this->distance,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user