title: Execute Multiple query if needed in Maatwebsite Excel package, Laravel
body: <p>I am trying to export excel from database in laravel. What i want to do is, there is a form by which admin can select "From" , "To" , "Bookingtype" and "Usertype"  . From and To's are date, bookingtype is like Booked or Cancelled and userype is Normal or agent.</p>
  
  <p>When admin select any kind of needs from this, for example when admin selects a date from , from and to then selects cancelled and Agent and press export button, they should get excel. And like wise they can execute different different queries.</p>
  
  <p>So far , i have accomplished to get excel by using three parameters like from, to and bookingtype. But how to use fourth parameter also which is user type ?</p>
  
  <p>This is my code:</p>
  
  <pre><code>public function query()
  {
      $from = $this-&gt;from;
      $to = $this-&gt;to;
      $bookingtype = $this-&gt;bookingtype;
      $usertype = $this-&gt;usertype;
  
      return Booking::query()-&gt;whereBetween('createdAt',[$from, $to])-&gt;where('status', '=', $bookingtype);
  }
  </code></pre>
  
  <p>And the important is , some time admin can only select from and to and they dont need other two options. So in that situation how to execute only that with one query function ? I am passing these from a from to controller and then class of maatwebsite. So what i am asking is, how to make a query which executes only what are been sent ?</p>
  
  <p>If we send from and to alone, then that should only execute and if we sent three parameters then that should execute like wise ! hope all understands. Do let me know if anything needed.</p>