I am doing a search filter, I have 3 inputs "municipality", "category", "keyword", I'm trying to insert a value into an array. IF input is not empty. eg:
public function search(Request $request)
{
$filter = array(["'visible', '=' , 1"],["'expire_date', '>', $current"]);
if(!empty($termn)){
$filter[] =["'title', 'LIKE' , '%'.$termn.'%'"];
}
if(!empty($request->input('category'))){
$filter[] = ["'category_id', '=', $input_category"];
}
if(!empty($request->input('municipality_id'))) {
$filter[] = ["'municipality_id', '=', $input_municipality"];
}
dd($filter);
$posts = Post::where($filter)->get();
}
But it is not filtered well, dd ($ filter) returns like this:

Perhaps the structure of the array is out of order, I also tried: the
search query laravel 5.2
but it does not work. WITHOUT dd ($ filter) I have this error:
SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in the SQL syntax; check the manual that corresponds to MariaDB server version for the right syntax to use near .. is null
and `'municipality_id', '=', 1` is null)' at line 1 (SQL: select *
from `posts` where (`'visible', '=' , 1` is null and `'expire_date',
'>', 2016-10-29 13:29:30` is null and `'category_id', '=', Scegli una
categoria`.. .is null and 'municipality_id', '=', 1null))
Thank you for your help!