title: Filtering on Laravel
body: <p>i have a project, in there i want to add filter feature. i can make it but i have a bug in my script. when i create new data booking in same title/post the filter list increases and have same title/post. but in there i just want to make a list of them.</p>
  
  <p>Image</p>
  
  <p><a href="https://i.stack.imgur.com/biNct.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/biNct.png" alt="wrong"></a></p>
  
  <p>its should be : </p>
  
  <ul>
  <li>Kost Alpha Charlie Delta Echo</li>
  <li>Kost Fanta Bintaro</li>
  <li>Home Test</li>
  </ul>
  
  <p>here is my controller : </p>
  
  
  
  
  
  <pre><code>public function getIndex()
      {
          $list = DB::table('data_kos')
          -&gt;orderBy('id','asc')
          -&gt;get();
  
          $limit = 10;
          $result = DB::table('data_kos')
          -&gt;orderBy('id','asc');
          if(Request::get('q')) {
              $q = Request::input("q");
              $posts-&gt;where('title','like','%'.Request::get('q').'%');
              $posts-&gt;orwhere("sex","like","%".Request::get("q")."%");
              $posts-&gt;orwhere("price","like","%".Request::get("q")."%");
          }
          if(Request::get('title')) {
              $result = $result-&gt;where("title",Request::get("title"));
          }
          $data['list'] = $list;
          $data['posts'] = $result-&gt;paginate($limit);
          return view('kost', $data);
      }
  </code></pre>
  
  
  
  <p>and this is my view :</p>
  
  
  
  
  
  <pre><code>@foreach($list as $row)
          &lt;li&gt;&lt;a href='{{ url("booking?title=$row-&gt;title") }}'&gt;{{ $row-&gt;title }}&lt;/a&gt;&lt;/li&gt;
          @endforeach
  </code></pre>
  
  
  
  <p>what improvements do i have to make to the code to achieve my goal?</p>