title: How to send and use an array in query, laravel
body: <p>I want to send an array of id to my controller, and use that controller in the &quot;whereIn&quot; clause. But it's not working. My codes are :</p>
  <p>From View: I am using ajax call to get value for package_id[] (you can see in the form below). the values are in array.</p>
  <pre><code>   &lt;form action=&quot;&quot; class=&quot;price-form&quot; method=&quot;post&quot;&gt;
         @csrf
         &lt;input type=&quot;text&quot; value=&quot;&quot; name=&quot;package_id[]&quot; id=&quot;package_id&quot;&gt;
         &lt;input type=&quot;text&quot; value=&quot;50&quot; name=&quot;member_number&quot; id=&quot;member_number&quot;&gt;
         &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;
     &lt;/form&gt;
  </code></pre>
  <p>from the controller: The product_id (in form of array) is dragged here in the controller.</p>
  <pre><code>public function get_package_price(Request $request) {
  
      if($request-&gt;ajax()){
          $member_number = $request-&gt;get('member_number');
  
          $package_ids = $request-&gt;get('package_id');
  
          if($member_number != '')
          {
              $get_price = DB::table('package_plans')-&gt;whereIn('package_id',$package_ids)
              -&gt;where('user_limit', '&gt;=', $member_number)-&gt;first();
  
              $get_plan_id = $get_price-&gt;id;
              $get_package_price = $get_price-&gt;price_in_usd;
              $user_limit = $get_price-&gt;user_limit;
       
          }
  
          $data = array(
              'get_package_price'  =&gt; $get_package_price,
              'get_plan_id'  =&gt; $get_plan_id,
              'user_limit'  =&gt; $user_limit
          );
  
          echo json_encode($data);
      }
  }
  </code></pre>
  <p>Codes from script:</p>
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
          $(&quot;#member_number&quot;).keyup(function(event){
              event.preventDefault();
              var member_number = $('#member_number').val();
              var package_id = $('#package_id').val();
              fetch_package_title(package_id, member_number);
  
              function fetch_package_title(package_id = '', member_number = ''){
              var currency_val = $('#currency_value').val();
  
              $.ajax({
                  url : 'get_package_price',
                  method : 'GET',
                  data : {package_id:package_id, member_number:member_number},
                  dataType : 'json',
                  success : function(data){
                      console.log(data.get_package_price);
                      var final_price = data.get_package_price;
                      var price_per_member =( data.get_package_price/data.user_limit ) 
                                            *member_number;
                      $('#package_price').html(data.get_package_price);
                      $('#cost_per_seat').html(price_per_member);
                      $('#cost_per_head').val(price_per_member);
                      $('#get_plan_id').val(data.get_plan_id);
                      $('#total_price').val(price_per_member);
                  }
              });
          }
  
        });
      });
    });
  
  &lt;/script&gt;
  </code></pre>