Build Laravel 13 ticket assistant with Docker, Livewire admin, and helpdesk scraper command

This commit is contained in:
SitiWeb
2026-04-29 13:11:39 +02:00
parent 141a1a3c9b
commit 3c4572bb12
58 changed files with 9377 additions and 455 deletions

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Repositories;
use App\DTOs\ArticleCandidateDTO;
use App\Models\Article;
use App\Repositories\Contracts\ArticleRepositoryInterface;
use Illuminate\Support\Facades\DB;
class ArticleRepository implements ArticleRepositoryInterface
{
public function findSimilarByEmbedding(array $embedding, int $limit = 5): array
{
$vector = '['.implode(',', array_map(static fn ($value) => (float) $value, $embedding)).']';
$rows = Article::query()
->select('articles.*')
->selectRaw('embedding <=> ?::vector as distance', [$vector])
->whereNotNull('embedding')
->orderByRaw('embedding <=> ?::vector', [$vector])
->limit($limit)
->get();
return $rows
->map(fn (Article $article) => ArticleCandidateDTO::fromArticle($article, (float) $article->distance))
->all();
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Repositories\Contracts;
use App\DTOs\ArticleCandidateDTO;
interface ArticleRepositoryInterface
{
/** @return array<ArticleCandidateDTO> */
public function findSimilarByEmbedding(array $embedding, int $limit = 5): array;
}