fix: Fix arcadia:import command

This commit is contained in:
Vincent BRIDIER 2025-10-24 11:19:49 +02:00
parent 29f8dfd724
commit b7392ec487
No known key found for this signature in database
GPG key ID: 8571BFA20420D512

View file

@ -127,20 +127,20 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->dam as $row) {
/** @var \App\Models\Article|null $record */
$record = Article::where('noArt', $row->noArt)->first();
$record = Article::where('noArt', (int)$row->noArt)->first();
if (!$record) {
$record = new Article();
$record->noArt = $row->noArt;
$record->noArt = (int)$row->noArt;
}
$record->libCcial = $row->libCcial;
$record->codMarq = $row->codMarq;
$record->libMarq = $row->libMarq;
$record->codFamVte = $row->codFamVte;
$record->libFamVte = $row->libFamVte;
$record->codGencodAdm = $row->codGencodAdm;
$record->codGencodSymb = $row->codGencodSymb;
$record->codGencodPds = $row->codGencodPds;
$record->utilisableGroupe = $row->utilisableGroupe;
$record->libCcial = (string)$row->libCcial;
$record->codMarq = (int)$row->codMarq;
$record->libMarq = (string)$row->libMarq;
$record->codFamVte = (int)$row->codFamVte;
$record->libFamVte = (string)$row->libFamVte;
$record->codGencodAdm = (string)$row->codGencodAdm;
$record->codGencodSymb = (string)$row->codGencodSymb;
$record->codGencodPds = (string)$row->codGencodPds;
$record->utilisableGroupe = (int)$row->utilisableGroupe;
$record->saveOrFail();
} //end foreach
}
@ -157,12 +157,12 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->dam as $row) {
/** @var \App\Models\Marque|null $record */
$record = Marque::where('codMarq', $row->codMarq)->first();
$record = Marque::where('codMarq', (int)$row->codMarq)->first();
if (!$record) {
$record = new Marque();
$record->codMarq = $row->codMarq;
$record->codMarq = (int)$row->codMarq;
}
$record->libMarq = $row->libMarq;
$record->libMarq = (string)$row->libMarq;
$record->saveOrFail();
}
}
@ -179,12 +179,12 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->mediaSujet as $row) {
/** @var \App\Models\Sujet|null $record */
$record = Sujet::where('codeSujet', $row->code)->first();
$record = Sujet::where('codeSujet', (int)$row->code)->first();
if (!$record) {
$record = new Sujet();
$record->codeSujet = $row->code;
$record->codeSujet = (int)$row->code;
}
$record->libelle = $row->libelle;
$record->libelle = (string)$row->libelle;
$record->saveOrFail();
}
}
@ -201,12 +201,12 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->mediatypemedia as $row) {
/** @var \App\Models\TypeMedia|null $record */
$record = TypeMedia::where('codeTypemedia', $row->code)->first();
$record = TypeMedia::where('codeTypemedia', (int)$row->code)->first();
if (!$record) {
$record = new TypeMedia();
$record->codeTypemedia = $row->code;
$record->codeTypemedia = (int)$row->code;
}
$record->libelle = $row->libelle;
$record->libelle = (string)$row->libelle;
$record->saveOrFail();
}
}
@ -223,13 +223,13 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->mediatypesvue as $row) {
/** @var \App\Models\TypeVue|null $record */
$record = TypeVue::where('codeTypevue', $row->code)->first();
$record = TypeVue::where('codeTypevue', (int)$row->code)->first();
if (!$record) {
$record = new TypeVue();
$record->codeTypevue = $row->code;
$record->codeTypevue = (int)$row->code;
}
$record->libelle = $row->libelle;
$record->sujet_id = $row->sujet_id->mediasujet->code;
$record->libelle = (string)$row->libelle;
$record->sujet_id = (int)$row->sujet_id->mediasujet->code;
$record->saveOrFail();
}
}
@ -246,14 +246,14 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->mediavariante as $row) {
/** @var \App\Models\TypeVue|null $record */
$record = Variante::where('codeVariante', $row->code)->first();
$record = Variante::where('codeVariante', (int)$row->code)->first();
if (!$record) {
$record = new Variante();
$record->codeVariante = $row->code;
$record->codeVariante = (int)$row->code;
}
$record->libelle = $row->libelle;
$record->sujet_id = $row->sujet_id->children()[0]->code;
$record->type_vue_id = $row->CodeTypeVue->mediatypesvue->code;
$record->libelle = (string)$row->libelle;
$record->sujet_id = (int)$row->sujet_id->children()[0]->code;
$record->type_vue_id = (int)$row->CodeTypeVue->mediatypesvue->code;
$record->saveOrFail();
}
}
@ -270,12 +270,12 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->SITE_PROD_GRP as $row) {
/** @var \App\Models\TypeVue|null $record */
$record = Site::where('id', $row->code)->first();
$record = Site::where('id', (int)$row->code)->first();
if (!$record) {
$record = new Site();
$record->id = $row->code;
$record->id = (int)$row->code;
}
$record->libelle = $row->libelle;
$record->libelle = (string)$row->libelle;
$record->saveOrFail();
}
}
@ -292,12 +292,12 @@ class ImportArcadiaModelFiles extends Command
/** @var \SimpleXMLElement $row */
foreach ($fileContent->dam as $row) {
/** @var \App\Models\TypeVue|null $record */
$record = Societe::where('id', $row->codSociete)->first();
$record = Societe::where('id', (int)$row->codSociete)->first();
if (!$record) {
$record = new Societe();
$record->id = $row->codSociete;
$record->id = (int)$row->codSociete;
}
$record->libelle = $row->nomSociete;
$record->libelle = (string)$row->nomSociete;
$record->saveOrFail();
}
}