53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Admin\Lists;
|
|
|
|
use KupShop\AdminBundle\AdminList\BaseList;
|
|
use KupShop\CatalogBundle\Query\Search;
|
|
use Query\QueryBuilder;
|
|
|
|
class ArtauthorsList extends BaseList
|
|
{
|
|
protected $tableName = 'articles_authors';
|
|
protected ?string $tableAlias = 'aa';
|
|
|
|
protected $tableDef = [
|
|
'id' => 'id',
|
|
'fields' => [
|
|
'ID' => ['field' => 'id', 'size' => 0.5],
|
|
'Jméno' => ['field' => 'name', 'render' => 'renderName', 'fieldType' => BaseList::TYPE_STRING],
|
|
'Přezdívka' => ['field' => 'nick', 'fieldType' => BaseList::TYPE_STRING],
|
|
'Poznámka' => ['field' => 'note', 'fieldType' => BaseList::TYPE_STRING],
|
|
'Registrován' => ['field' => 'date_reg', 'render' => 'renderDate', 'fieldType' => BaseList::TYPE_DATE],
|
|
],
|
|
];
|
|
|
|
public function renderName($values, $column)
|
|
{
|
|
$name = $this->getListRowValue($values, $column['field']);
|
|
|
|
return $name.' '.$values['surname'];
|
|
}
|
|
|
|
public function getFilterQuery(): QueryBuilder
|
|
{
|
|
$qb = parent::getFilterQuery();
|
|
|
|
if ($name = getVal('name')) {
|
|
$qb->andWhere(Search::searchFields(
|
|
search_term: $name,
|
|
fields: [
|
|
['field' => 'name', 'match' => 'both'],
|
|
['field' => 'surname', 'match' => 'both'],
|
|
['field' => 'nick', 'match' => 'both'],
|
|
],
|
|
operator: 'OR'
|
|
));
|
|
}
|
|
|
|
return $qb;
|
|
}
|
|
}
|
|
|
|
return ArtauthorsList::class;
|