title: Insert Multiple Checkbox in multiple rows in database using laravel
body: <p>i want to insert the multiple checkbox values in multiple rows at same time in  database. i get the value of checkbox and when submit the form it stores null value in database. i think i m unable to pass the checkbox value from the view to controller.... 
  Here is my Controller code: </p>
  
  <pre><code>`public function create(Request $request) {`
          `$treatment_id = json_decode(Input::get('treatment_id'), true); 
          //assuming you use json to submit the multiple countries`
  
   $user_countries = array();
   foreach($countries as $country)
   {
       $treatment_id[]=new Price(array('treatment_id'=&gt;$treatment_id));
   }
  
      //save the countries into the DB
  
      $user-&gt;prices()-&gt;saveMany($treatment_id);
      $count=$request-&gt;input('counter');
      for ($i=1; $i&lt;=$count; $i++) { 
          $prices= new Price;
          $hospital_id=$request-&gt;input('hospital_id');
          $category_id=$request-&gt;input('category_id');
          $treatment_id=$request-&gt;input('treatment_id');   
          $price=$request-&gt;input('price');   
  
          $prices-&gt;hospital_id=$hospital_id;
          $prices-&gt;category_id=$category_id;
          $prices-&gt;treatment_id=$treatment_id;
          $prices-&gt;price=$price;
  
          $prices-&gt;save();
        }
      return view('admin.viewprice');
  }
  </code></pre>
  
  <p>and here is my view/blade code: in this page I am fetching the input checkbox value name or price section using ajax in <code>productname</code> class section</p>
  
  <pre><code> &lt;form role="form" action="{{route('createprice')}}" method="POST" enctype="multipart/form-data"&gt;
               {{ csrf_field() }}
              &lt;input type="hidden" name="counter" id="counter" value="1" /&gt; 
                  &lt;select class="form-control" name="hospital_id"&gt;
                  @foreach($hospitals as $key=&gt; $hospital)
                  &lt;option value="{{$hospital-&gt;id}}"&gt;{{$hospital-&gt;hospital_name}}&lt;/option&gt;
                  @endforeach
                 &lt;/select&gt;
                 &lt;select style="width:200px;" class="productcategory form-control" id="prod_cat_id" name="category_id"&gt;
      &lt;option value="0" disabled="true" selected="true"&gt;--Select--&lt;/option&gt;
      @foreach($categories as $key=&gt; $category)
          &lt;option value="{{$category-&gt;id}}"&gt;{{$category-&gt;name}}&lt;/option&gt;
      @endforeach
      &lt;/select&gt;
      &lt;div class="productname" id="add_schedule"&gt;
  
       &lt;/div&gt;
       `Ajax Request`
       op+='&lt;option value="0" selected disabled&gt; Chose Product&lt;/option&gt;';
                  for(var i=1; i&lt;data.length; i++) {
          document.getElementById('counter').value = i;                     
                        op+='&lt;div class="col-md-4"&gt;&lt;input type="checkbox" name="treatment_id[]" value="'+data[i].id+'"&gt;'+data[i].treatment_name+'&lt;/div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;'+'&lt;div class="col-md-4"&gt;&lt;input type="text" name="price[]" /&gt;&lt;/div&gt;';
  </code></pre>
  
  <p>I don't know where I making mistake ... if anybody have solution then please help me ....</p>