title: Laravel - Undefined variable: dropdowns
body: <p>I am trying to filter using dropdown (select), but I got this error:</p>
  
  <blockquote>
    <p>Undefined variable: dropdowns (View: C:\xampp\htdocs\bbnaijareport\resources\views\report\bbnaijaonetimebillingsReport.blade.php)"</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/l3CrK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l3CrK.png" alt="error"></a></p>
  
  <p>model</p>
  
  <pre><code>   protected $fillable = [
      'msisdn',
      'created_at',
      'amount',
      'billing_channel',   
  ];
  
           public static function getFilters() {
          $filter = DB::select(DB::raw('SELECT DISTINCT billing_channel AS filt FROM bbnaija_one_time_billings'));
  
          foreach ($filter as $key =&gt; $value) { 
            $dropdown[$key] = $value-&gt;filt; 
          }               
         } 
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>    public function bbnaijaonetimebillingsReport(Request $request)
  {
      $data['title'] = 'Bbnaija One Time Billings';
  
      $billings = DB::table('bbnaija_one_time_billings')
      -&gt;select(
         'msisdn', 
         'trans_id',
         'ext_id',
           DB::raw('created_at as created_date'),
         'amount',
         'is_complete_transactions',
         'billing_channel'
    )               
   -&gt;orderByRaw('created_at DESC'); 
  
      $dropdowns=BbnaijaOneTimeBillings::getFilters();
  
      $start_date = $request-&gt;start_date;
      $end_date = $request-&gt;end_date;         
  
      $render=[];       
      if(isset($request-&gt;msisdn))
      {
          $billings=$billings-&gt;where('msisdn','like','%'.$request-&gt;msisdn.'%');
          $render['msisdn']=$request-&gt;msisdn;
      }   
      if(isset($request-&gt;billing_channel))
      {
          $billings=$billings-&gt;where('billing_channel',$request-&gt;billing_channel);
          $render['billing_channel']=$request-&gt;billing_channel;
      }
      if(isset($request-&gt;start_date) &amp;&amp; isset($request-&gt;end_date))
      {
          $billings=$billings-&gt;whereBetween('created_at',[$start_date.' 00:00:00',$end_date.' 23:59:59']);
          $render['start_date']=$request-&gt;start_date;
          $render['end_date']=$request-&gt;end_date;
      }elseif(isset($request-&gt;start_date))
      {
          $billings=$billings-&gt;where('created_at',$request-&gt;start_date);
          $render['start_date']=$request-&gt;start_date;
      }         
      $billings= $billings-&gt;orderBy('created_at','DESC');
      $billings= $billings-&gt;paginate(15);
      $billings= $billings-&gt;appends($render);
       $data["dropdowns"] = $dropdowns;
      $data['billings'] = $billings;
  
  return view('report.bbnaijaonetimebillingsReport',$data);        
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>    &lt;div class="row" style="margin-bottom: 10px"&gt;
      {{ Form::model(request(),['method'=&gt;'get']) }}
      &lt;div class="col-sm-2"&gt;
           {{ Form::text('msisdn',null,['class'=&gt;'form-control','placeholder'=&gt;'MSISDN']) }}
      &lt;/div&gt;
      &lt;div class="col-sm-2"&gt;
           {{ Form::select('billing_channel',$dropdowns,null,['class'=&gt;'form-control','placeholder'=&gt;'Select Channel']) }}
      &lt;/div&gt;        
      &lt;div class="col-sm-3"&gt;
          {{ Form::date('start_date',null,['class'=&gt;'form-control','placeholder'=&gt;'Date']) }}
      &lt;/div&gt;
      &lt;div class="col-sm-3"&gt;
          {{ Form::date('end_date',null,['class'=&gt;'form-control','placeholder'=&gt;'Date']) }}
      &lt;/div&gt;           
      &lt;div class="col-xs-2"&gt;
          {{ Form::submit('Search',['class'=&gt;'btn btn-warning']) }}
          &lt;a href="{{ route('bbnaijaonetimebillingsexport') }}" class="btn btn-primary"&gt;&lt;i class="fa fa-file-excel-o"&gt;&lt;/i&gt; Excel&lt;/a&gt;
      &lt;/div&gt;
      {{ Form::close() }}
  &lt;/div&gt;
  </code></pre>
  
  <p>The problem is from</p>
  
  <blockquote>
    <p>{{ Form::select('billing_channel',$dropdowns,null,['class'=>'form-control','placeholder'=>'Select Channel']) }}</p>
  </blockquote>
  
  <p>I want to filter using billing_channel.  It is a field from the table.</p>
  
  <p>How do I resolve the issue</p>
  
  <p><a href="https://i.stack.imgur.com/tWs0b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tWs0b.png" alt="new_error"></a></p>