ldc-bogt/app/Console/Commands/MajEleveurs.php
Thibault Richy c87fb7e8e7 Tryout speed
2020-01-29 14:04:06 +01:00

61 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Moba;
class MajEleveurs extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'maj:moba';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
setlocale(LC_CTYPE, 'en_US.utf8');
$path = base_path("resources/flux_in/maj/*.csv");
foreach (glob($path) as $file){
$flag = true;
$line = 0;
if (($handle = fopen($file, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 50000, ";", '"')) !== FALSE) {
if($flag) { $flag = false; continue; }
$line++;
$code_boite = $data[0];
$ean13 = $data[7];
$mobas = Moba::where('code_boite', '=', $code_boite)->update(['ean13' => $data[7]]);
echo $line."\n\r";
}
}
}
}
}