65 lines
1.5 KiB
PHP
65 lines
1.5 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)->andWhere('ean13', '=', '')->update(['ean13' => $data[7]]);
|
|
echo $line . "\n\r";
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|