Fix import add ean13 && command maj ean13
This commit is contained in:
parent
6df307c911
commit
c274eecbe0
3 changed files with 76 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ class ImportMoba extends Command
|
|||
$libelle_produit = $data[4];
|
||||
$lot_externe = $data[5];
|
||||
$dcr = $data[6];
|
||||
$ean = $data[7];
|
||||
list($d_dcr, $m_dcr, $y_dcr) = explode('/', $dcr);
|
||||
$dateDcr = $y_dcr.'-'.$m_dcr.'-'.$d_dcr;
|
||||
|
||||
|
|
@ -81,6 +82,7 @@ class ImportMoba extends Command
|
|||
$moba->lot_externe = $lot_externe;
|
||||
$moba->dcr = $dateDcr;
|
||||
$moba->date_emballage = $date_emballage;
|
||||
$moba->ean13 = $ean;
|
||||
$moba->save();
|
||||
|
||||
$lines++;
|
||||
|
|
|
|||
69
app/Console/Commands/MajEleveurs.php
Normal file
69
app/Console/Commands/MajEleveurs.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?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)->get();
|
||||
if($mobas && count($mobas) > 0){
|
||||
foreach ($mobas as $moba) {
|
||||
if($moba->ean13 == ""){
|
||||
$moba->ean13 = $ean13;
|
||||
$moba->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $line."\n\r";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,11 @@
|
|||
<span class="green">PAR : </span> {{$eleveurs[0]->prenom}} {{$eleveurs[0]->nom}} <br>
|
||||
<span class="green">À : </span> {{$eleveurs[0]->ville}} ({{$eleveurs[0]->cp}})
|
||||
</p>
|
||||
<img src="/loue/img/elevage.jpg" alt="Élevage">
|
||||
@if (isset($eleveurs[0]->path_photo1) && $eleveurs[0]->path_photo1 != '')
|
||||
<img src="{{ asset($eleveurs[0]->path_photo1) }}" alt="Élevage">
|
||||
@else
|
||||
<img src="/loue/img/elevage.jpg" alt="Élevage">
|
||||
@endif
|
||||
<div class="bottom one">
|
||||
<a href="{{route('portraitEleveur', ['id' => $id, 'eleveurId' => $eleveurs[0]->id])}}">en savoir + sur</a>
|
||||
<p>{{$eleveurs[0]->prenom}} {{$eleveurs[0]->nom}}</p>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue