Laravel 5.2 - filter with array
<p>i'm doing a search filter, i have 3 inputs "municipality", "category", "keyword", i'm tryng to insert value to array IF input is not empty. like this:</p>

<pre><code>public function search(Request $request)
    {


        $filter = array(["'visible', '=' , 1"],["'expire_date', '&gt;', $current"]);

        if(!empty($termn)){
                $filter[] =["'title', 'LIKE' , '%'.$termn.'%'"];
        }
        if(!empty($request-&gt;input('category'))){
                $filter[] = ["'category_id', '=', $input_category"];
        }
        if(!empty($request-&gt;input('municipality_id')))  {
                $filter[] = ["'municipality_id', '=', $input_municipality"];
        }

        dd($filter);

        $posts = Post::where($filter)-&gt;get();
}
</code></pre>

<p>But it is not filtering well, the dd($filter) return like this: 
<a href="https://i.stack.imgur.com/fA7I5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fA7I5.png" alt="enter image description here"></a></p>

<p>maybe the structure of array is not ok, i tried also like this:
<a href="https://stackoverflow.com/questions/40186017/laravel-5-2-search-query">laravel 5.2 search query</a>
but it doen't work. 
WITHOUT dd($filter) i have this error:</p>

<blockquote>
  <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
  error in your SQL syntax; check the manual that corresponds to your
  MariaDB server version for the right syntax to use near '.<code>is null
  and `'municipality_id', '=', 1` is null)' at line 1 (SQL: select *
  from `posts` where (`'visible', '=' , 1` is null and `'expire_date',
  '&gt;', 2016-10-29 13:29:30` is null and `'category_id', '=', Scegli una
  categoria`.</code>.<code>.</code> is null and <code>'municipality_id', '=', 1</code> is null))</p>
</blockquote>

<p>Thank you for your help!</p>