PLease, somebody, help me with filters. I have 3 tables: complaint, frontend_tag, frontendtags_complaints I heed to filter complaints by frontend_tag
here is my filter code:
$this->crud->addFilter([
'name' => 'frontendtags',
'type' => 'select2',
'label'=> 'FE Tag'
], function() {
return \App\Models\FrontendTags::all()->pluck('name', 'id')->toArray();
}, function($value) {
return $this->crud->query->whereHas('frontendtags', function ($q) use ($value) {
$q->where('tag_id', $value);
});
});
here is my relation code:
public function frontendtags()
{
return $this->belongsToMany('App\Models\FrontendTags', 'frontendtags_complaints', 'complaint_id', 'tag_id');
}
The filter is not working.
via Roman Zaglinskyi