mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 01:49:05 +02:00
Implement a user friendly part select element.
This commit is contained in:
parent
c78bc01d23
commit
670dd76ef5
5 changed files with 175 additions and 3 deletions
|
@ -66,4 +66,24 @@ class PartRepository extends NamedDBElementRepository
|
|||
|
||||
return (int) ($query->getSingleScalarResult() ?? 0);
|
||||
}
|
||||
|
||||
public function autocompleteSearch(string $query, int $max_limits = 50): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('part');
|
||||
$qb->select('part')
|
||||
->leftJoin('part.category', 'category')
|
||||
|
||||
->where('part.name LIKE :query')
|
||||
->orWhere('part.description LIKE :query')
|
||||
->orWhere('category.name LIKE :query')
|
||||
|
||||
;
|
||||
|
||||
$qb->setParameter('query', '%'.$query.'%');
|
||||
|
||||
$qb->setMaxResults($max_limits);
|
||||
$qb->orderBy('part.name', 'ASC');
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue