title: laravel: I cannot complete search form
body: <p>I am building a search form for <code>posts</code> table.</p>
  
  <p>Now I can search description, but when I select a category or date, and search, the result page shows all the posts. Which means search functionality for 'category' and 'date' don't work.</p>
  
  <p>I don't want to build a strict search functionality, so I used <code>orWhere</code> query clause.  </p>
  
  <p><strong>web.php</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>Route::get('results', 'ResultsController@index')-&gt;name('posts.result');
  </code></pre>
  
  <p><code>ResultsController.php</code></p>
  
  <pre class="lang-php prettyprint-override"><code>public function index(Request $request)
  {
      $keyword = $request-&gt;get('keyword');
      $category = $request-&gt;get('category_id');
      $date = $request-&gt;get('date');
  
      if ($keyword || $category || $date) {
          $posts = Post::Where('keyword', 'LIKE', '%' . $keyword . '%')
              -&gt;orWhere('category_id', $category)
              -&gt;orWhere('date', $date)
              -&gt;paginate(10);
          return view('posts.result', compact('posts'));
      } else {
          $posts = Post::latest()
              -&gt;orderBy('date', 'asc')
              -&gt;paginate(10);
          return view('posts.result', compact('posts'));
      }
  }
  </code></pre>
  
  <p><strong>posts table migration</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>Schema::create('posts', function (Blueprint $table) {
      $table-&gt;bigIncrements('id');
      $table-&gt;string('image');
      $table-&gt;unsignedBigInteger('category_id');
      $table-&gt;string('title');
      $table-&gt;string('place');
      $table-&gt;string('map');
      $table-&gt;date('date');
      $table-&gt;string('organizer');
      $table-&gt;string('organizer_link');
      $table-&gt;timestamp('published_at')-&gt;nullable();
      $table-&gt;text('description');
      $table-&gt;timestamps();
  });
  </code></pre>
  
  <p><strong>result.blade.php</strong></p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="{{ route('posts.result') }}" class="search" method="GET"&gt;
      &lt;input type="text" name="description" class="search_text" placeholder="Enter the key words"&gt;
      &lt;select name="category" id="select" class="Genre"&gt;
          &lt;option value="" hidden name="category"&gt;Category&lt;/option&gt;
          @foreach(App\Category::all() as $category)
          &lt;option value="{{$category-&gt;id}}"&gt;{{$category-&gt;name}}&lt;/option&gt;
          @endforeach
      &lt;/select&gt;
      &lt;input type="text" name="date" class="search_date" id="date" placeholder="Choose date"&gt;
      &lt;button type="submit" class="test"&gt;
          &lt;i class="fas fa-search "&gt;&lt;/i&gt;
      &lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>