title: Laravel: Check on which form submitted the request
body: <p>On my website, users can display posts created by other users. However, I have 2 select boxes, one for ordering by name or date and the other is ordering by category. The way I have done it is incorrect and I am aware of that. The simple reason for this is that I don't know how to make an if check on which form submitted the request.</p>
  
  <p>Here is my controller method for displaying the events:</p>
  
  <pre><code>public function getEvents(Request $request){
      if($request['sort'] == "created_at"){
          $posts = Post::orderBy('created_at', 'desc')-&gt;get();
      }
      elseif($request['sort'] == "title"){
          $posts = Post::orderBy('title', 'desc')-&gt;get();
      }
      elseif($request['category'] == "sport"){
          $post = Post::where('type', '=', 'sport' )-&gt;get();
      }
      elseif($request['category'] == "culture"){
          $post = Post::where('type', '=', 'culture' )-&gt;get();
      }
      elseif($request['category'] == "other"){
          $post = Post::where('type', '=', 'other' )-&gt;get();
      }
      else{
          $posts = Post::orderBy('created_at', 'desc')-&gt;get();
      }
  
      return view ('eventspage',  ['posts' =&gt; $posts]);
  }
  </code></pre>
  
  <p>This is currently incorrect, I want it to follow this structure:</p>
  
  <pre><code>if(request submitted by 'sort')
     then do this...
  elseif(request submitted by 'category')
     then do this...
  </code></pre>
  
  <p>Here is my view containing the 2 select boxes:</p>
  
  <pre><code>&lt;div class="row"&gt;
      &lt;div class="col-md-6"&gt;
          &lt;form action="{{ route('events') }}"&gt;
              &lt;select name="category" onchange="this.form.submit()" class="form-control"&gt;
                  &lt;option value="sport"&gt;sport&lt;/option&gt;
                  &lt;option value="culture"&gt;Culture&lt;/option&gt;
                  &lt;option value="other"&gt;Other&lt;/option&gt;
              &lt;/select&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;div class="col-md-6"&gt;
          &lt;form action="{{ route('events') }}"&gt;    
              &lt;select name="sort" onchange="this.form.submit()" class="form-control"&gt;
                  &lt;option value="created_at"&gt;Date&lt;/option&gt;
                  &lt;option value="title"&gt;Title&lt;/option&gt;
              &lt;/select&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>