<?php

namespace App\Imports;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\ToArray;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use DB;
use Carbon\Carbon;

class StockImport implements ToArray, WithHeadingRow
{
    /**
    * @param Collection $collection
    */
    public function array(array $data)
    {
        //dd($data);
		$today = date('Y-m-d');
		foreach($data as $produit){
			DB::table('stock_magasin')->insert(
			[
				'produit_id' => $produit['number'],
				'qte' => $produit['qte'],
				'date' => $today,
				'en_stock' => 0,
				'apres' => $produit['qte'],
				'type_operation' => 'Inventaire',
				'magasin_id' => 1,
			]
		);
		}	
	}
}
