Skip to content

Commit

Permalink
Merge pull request #329 from devansh-webkul/filter-issue
Browse files Browse the repository at this point in the history
Some query fixed #321
  • Loading branch information
jitendra-webkul authored Sep 28, 2021
2 parents a3937e9 + 3eaac3c commit a5b0789
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public function prepareQueryBuilder()
->select(
'activities.*',
'leads.id as lead_id',
'leads.title as lead_title',
'users.id as created_by_id',
'users.name as created_by',
'leads.title as lead_title',
)
->leftJoin('activity_participants', 'activities.id', '=', 'activity_participants.activity_id')
->leftJoin('lead_activities', 'activities.id', '=', 'lead_activities.activity_id')
Expand Down Expand Up @@ -58,6 +58,7 @@ public function prepareQueryBuilder()
$this->addFilter('created_by', 'users.name');
$this->addFilter('created_by_id', 'activities.user_id');
$this->addFilter('created_at', 'activities.created_at');
$this->addFilter('lead_title', 'leads.title');

$this->setQueryBuilder($queryBuilder);
}
Expand Down Expand Up @@ -93,7 +94,7 @@ public function addColumns()
]);

$this->addColumn([
'index' => 'lead',
'index' => 'lead_title',
'label' => trans('admin::app.datagrid.lead'),
'type' => 'string',
'searchable' => false,
Expand Down
10 changes: 7 additions & 3 deletions packages/Webkul/UI/src/DataGrid/Traits/ProvideCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,13 @@ private function filterCollection($collection, $info, $columnType, $columnName)
break;

case 'in':
foreach (explode(',', $filterValue) as $value) {
$this->resolve($collection, $columnName, 'like', "%{$value}%", 'orWhere');
}
$collection->where(function ($query) use ($columnName, $filterValue) {
foreach (explode(',', $filterValue) as $value) {
$query->orWhere(function ($query) use ($columnName, $value) {
$this->resolve($query, $columnName, 'like', "%{$value}%", 'orWhere');
});
}
});
break;

case 'bw':
Expand Down

0 comments on commit a5b0789

Please sign in to comment.