Open majacirkova1989 opened 9 years ago
Sorry, I don't understand your question. Can you rephrase it or explain what you are planning to do with examples?
Well i planing to do this:
Application with grid is using this query for exmaple:
$query = new EloquentDataProvider( Contact::join('company', 'company.contact_id', '=', 'contact.id') ->join('person', 'contact....))
$grid = new Grid( (new GridConfig) ->setDataProvider($query) ..)
So i have filter which i one on execution to change(delete - overwritten) $query to different one . For example : (new CheckGroup) ->setName('group') ->setVariants($group_name) ->setFilteringFunc( function ($filter_fields_group, EloquentDataProvider $dp) { /* @var Illuminate\Database\Eloquent\Builder $builder / //dd($filter_fields_group); //dd($filter_fields_group[0]); if($filter_fields_group[0] == 'on') { //$builder = $dp->getBuilder()->delete(); // deletes all contacts //$builder = $dp->getBuilder()-> //$builder->where('groupable.group_id', '=', 'group.id', 'and'); $ids = \DB::table('groupable')->lists('groupable.id'); $ids_not = Contact::whereNotIn('contact.id', $ids)->get();
for ($i = 0; $i < count($ids_not); $i++) {
//print_r($ids_not[$i]->id);
$builder = $dp->getBuilder();
$builder->where('contact.id', '=',$ids_not[$i]->id,'or');
}
//dd('vleze');
}
else {
$builder = $dp->getBuilder();
$builder->where('groupable.group_id', '=', 'group.id', 'and');
for ($i = 0; $i < count($filter_fields_group); $i++) {
$builder->where('group.group', '=',$filter_fields_group[$i],'or');
}
}
})
->setDefaultValue($filter_fields_group)
Hey , is it possible to has two basic queries on click to change it on grid ??
Thanks