display data to the table depending on the user
display data to the table depending on the user
majkellvz
Posts: 8Questions: 3Answers: 0
I need to show only the properties the active user has registered to be sold.
$table = $this->createDataTable()
->add('name', TextColumn::class, [
'searchable' => true,
'globalSearchable' => true,
'label' => 'Name'
])
->add('contact', TextColumn::class, [
'searchable' => true,
'label' => 'Contact',
'field' => 'contact.name'
])
->add('user', TextColumn::class, [
'searchable' => true,
'label' => 'Agent',
'field' => 'user.username'
])
->add('id', TextColumn::class, [
'searchable' => false,
'label' => ' '
])
->add('issold', TextColumn::class, [
'searchable' => false,
'label' => 'Sold/Un-Sold'
])
->createAdapter(ORMAdapter::class, [
'entity' => Property::class,
])
->handleRequest($request);
This discussion has been closed.
Answers
I'm not sure what API you are using there (it isn't one of ours), but I'd suggest breaking the chain and adding
if
statements:Allan
https://omines.github.io/datatables-bundle/ this is the guide I am using.
$table->createAdapter(ORMAdapter::class, [
'entity' => Property::class,
'criteria' => [
function (QueryBuilder $builder, $user) {
$builder->andWhere($builder->expr()->like('p.user', ':user'))->setParameter('user', $user);
},
new SearchCriteriaProvider(),
],
]);
this is the code I came up and still not working