- trop de trucs d'un coup... je vais faire attention ensuite ^^'
This commit is contained in:
28
src/Twig/Components/Search.php
Normal file
28
src/Twig/Components/Search.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Twig\Components;
|
||||
|
||||
use App\Repository\MangaRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
|
||||
use Symfony\UX\LiveComponent\Attribute\LiveProp;
|
||||
use Symfony\UX\LiveComponent\DefaultActionTrait;
|
||||
|
||||
#[AsLiveComponent]
|
||||
final class Search
|
||||
{
|
||||
use DefaultActionTrait;
|
||||
|
||||
#[LiveProp (writable: true)]
|
||||
public ?string $query = null;
|
||||
|
||||
public function __construct(private readonly MangaRepository $mangaRepository)
|
||||
{
|
||||
}
|
||||
|
||||
public function getMangas(): array
|
||||
{
|
||||
return $this->query ? $this->mangaRepository->findByTitle($this->query) : [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user