title: How can I insert the array value into my table by using Laravel Eloquent ORM?
body: <p>Below is the array. I would be like to insert the array into my "sells" table by Laravel eloquent ORM system. but </p>
  
  <pre><code>$data = [
                  'products' =&gt; [
                      'product_id' =&gt; ['1', '3', '4'],
                      'quantity' =&gt; ['5', '5', '4'],
                      'product_discount' =&gt; ['30', '0', '5'],
                      'discount_unit' =&gt; ['%', 'tk', '%'],
                  ],
  
                  'customer_id' =&gt; 1,
                  'total_discount' =&gt; 50,
                  'shiping_charge' =&gt; 10,
                  'net_payable' =&gt; 5000,
  
                  'payments' =&gt; [
                      'payment_method' =&gt; ['cash', 'card', 'check'],
                      'payment_amount' =&gt; ['500', '7000', '400'],
                  ],
              ];
  </code></pre>
  
  <p>Here is the Eloquent Code to insert data into sells table. </p>
  
  <p>$sell = new Sell();</p>
  
  <pre><code>    $sell-&gt;sells_code = 'SCN-' . rand(time(), 1000);
  
      $sell-&gt;sells_date = date('Y-m-d');
  
      foreach ($data['products']['product_id'] as $value){
          $sell-&gt;product_id = $value . ",";
      }
  
  
  
      foreach ($data['products']['quantity'] as $value){
          $sell-&gt;product_quantity = $value . ",";
      }
  
      foreach ($data['products']['product_discount'] as $value){
          $sell-&gt;product_discount = $value . ",";
      }
  
      foreach ($data['products']['discount_unit'] as $value){
          $sell-&gt;product_discount_unit = $value . ",";
      }
  
  
      $sell-&gt;customer_id = $data['customer_id'];
      $sell-&gt;company_name = 'Undefined';
      $sell-&gt;warehouse_id = 1;
      $sell-&gt;total_discount = $data['total_discount'];
  
      $sell-&gt;shipping_address = 'Undefined Address';
      $sell-&gt;shipping_charge = 0;
      $sell-&gt;net_payable = $data['net_payable'];
  
  
      foreach ($data['payments']['payment_method'] as $value){
          $sell-&gt;payment_method = $value . ",";
      }
  
      foreach ($data['payments']['payment_amount'] as $value){
          $sell-&gt;payment_amount = $value . ",";
      }
  
  
      $sell-&gt;payment_date= date('Y-m-d');
      $sell-&gt;note = 'Nothing';
      $sell-&gt;sells_Status = 'Success';
      $sell-&gt;biller = 'Mahady';
  
  
      $sell-&gt;save();
  </code></pre>
  
  <p>Are you please to share the effective and easiest way to insert array value into a mysql database table?</p>