refactor: cleanup fake arcadia tables used for development
This commit is contained in:
parent
f7c7bb3db6
commit
f88694110d
18 changed files with 1 additions and 1106 deletions
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\ArcadiaBrand;
|
||||
|
||||
/**
|
||||
* @extends Factory<ArcadiaBrand>
|
||||
*/
|
||||
final class ArcadiaBrandFactory extends Factory
|
||||
{
|
||||
protected $model = ArcadiaBrand::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'code' => fake()->unique()->numberBetween(100, 999),
|
||||
'libelle' => fake()->company(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ namespace Database\Factories;
|
|||
use Domain\Models\ValueObjects\Brand\BrandName;
|
||||
use Domain\Services\BrandCodeGenerator;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\ArcadiaBrand;
|
||||
use Infra\Database\Models\Brand;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
|
@ -31,7 +30,7 @@ final class BrandFactory extends Factory
|
|||
return [
|
||||
'id' => Uuid::uuid7()->toString(),
|
||||
'name' => $name,
|
||||
'arcadia_id' => ArcadiaBrand::factory(),
|
||||
'arcadia_id' => fake()->unique()->numberBetween(1, 9999),
|
||||
'uwil_public_id' => $code->value,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\Employee;
|
||||
|
||||
/**
|
||||
* @extends Factory<Employee>
|
||||
*/
|
||||
final class EmployeeFactory extends Factory
|
||||
{
|
||||
protected $model = Employee::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'public_employee_number' => (string) fake()->unique()->numberBetween(1000000, 9999999),
|
||||
'last_name' => strtoupper(fake()->lastName()),
|
||||
'first_name' => fake()->firstName(),
|
||||
'start_date' => '2024-01-15',
|
||||
'end_date' => null,
|
||||
'planned_end_date' => null,
|
||||
'establishment' => '01',
|
||||
'site' => 'LDCSER',
|
||||
'service' => '097',
|
||||
'created_at' => now()->toDateTimeString(),
|
||||
'updated_at' => now()->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
|
||||
/**
|
||||
* @extends Factory<IncoCompo>
|
||||
*/
|
||||
final class IncoCompoFactory extends Factory
|
||||
{
|
||||
protected $model = IncoCompo::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
$idInco = (string) fake()->unique()->numberBetween(10000, 99999);
|
||||
|
||||
return [
|
||||
'id' => $idInco,
|
||||
'id_inco' => $idInco,
|
||||
'identification' => [
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'number' => $idInco,
|
||||
'source' => 'LDC',
|
||||
],
|
||||
'energy' => [
|
||||
'reference' => ['size' => '100g', 'energyKj' => '500', 'energyKcal' => '120'],
|
||||
'portion' => ['size' => '150g', 'energyKj' => '750', 'energyKcal' => '180'],
|
||||
],
|
||||
'reference_macronutrients' => [
|
||||
'fat' => ['amount' => '10.0', 'precision' => null],
|
||||
'saturatedFat' => ['amount' => '2.5', 'precision' => null],
|
||||
'carbohydrates' => ['amount' => '0.5', 'precision' => null],
|
||||
'sugars' => ['amount' => '0.1', 'precision' => null],
|
||||
'fiber' => ['amount' => '0.0', 'precision' => null],
|
||||
'protein' => ['amount' => '22.0', 'precision' => null],
|
||||
'salt' => ['amount' => '1.2', 'precision' => null],
|
||||
'sodium' => '0.48',
|
||||
],
|
||||
'portion_macronutrients' => [
|
||||
'fat' => ['amount' => '15.0', 'precision' => null],
|
||||
'saturatedFat' => ['amount' => '3.75', 'precision' => null],
|
||||
'carbohydrates' => ['amount' => '0.75', 'precision' => null],
|
||||
'sugars' => ['amount' => '0.15', 'precision' => null],
|
||||
'fiber' => ['amount' => '0.0', 'precision' => null],
|
||||
'protein' => ['amount' => '33.0', 'precision' => null],
|
||||
'salt' => ['amount' => '1.8', 'precision' => null],
|
||||
'sodium' => '0.72',
|
||||
],
|
||||
'fresh_produce_and_nuts' => [
|
||||
'reference' => ['fruits' => '0', 'nuts' => '0'],
|
||||
'portion' => ['fruits' => '0', 'nuts' => '0'],
|
||||
'freshFnlPercentage' => ['value' => '0'],
|
||||
'fruitsPercentage' => ['value' => '0'],
|
||||
],
|
||||
'reference_intakes' => [
|
||||
'energyE14' => ['value' => '6%'],
|
||||
'energyKj' => ['value' => '6%'],
|
||||
'fat' => ['value' => '14%'],
|
||||
'saturatedFat' => ['value' => '13%'],
|
||||
'carbohydrates' => ['value' => '0%'],
|
||||
'sugars' => ['value' => '0%'],
|
||||
'protein' => ['value' => '44%'],
|
||||
'salt' => ['value' => '20%'],
|
||||
'portionAmount' => '150g',
|
||||
'proteinToLipidRatio' => '2.2',
|
||||
],
|
||||
'nutri_score' => [
|
||||
'class' => 'A',
|
||||
'score' => -2,
|
||||
'isFnl' => false,
|
||||
'status' => 'valid',
|
||||
],
|
||||
'nutri_score_points' => [
|
||||
'energyPoints' => '1',
|
||||
'saturatedFatPoints' => '1',
|
||||
'sugarsPoints' => '0',
|
||||
'saltPoints' => '2',
|
||||
'fiberPoints' => '0',
|
||||
'proteinPoints' => '5',
|
||||
'freshFnlPoints' => '0',
|
||||
],
|
||||
'minerals' => [
|
||||
'calcium' => '12.0',
|
||||
'magnesium' => '25.0',
|
||||
'potassium' => '300.0',
|
||||
'phosphorus' => '200.0',
|
||||
'chloride' => '0.0',
|
||||
'iron' => '1.1',
|
||||
'zinc' => '1.5',
|
||||
'copper' => '0.1',
|
||||
'manganese' => '0.0',
|
||||
'selenium' => '15.0',
|
||||
'iodine' => '0.0',
|
||||
'chromium' => '0.0',
|
||||
'molybdenum' => '0.0',
|
||||
'sulfur' => '0.0',
|
||||
'nitrates' => '0.0',
|
||||
],
|
||||
'vitamins' => [
|
||||
'vitaminA' => '0.0',
|
||||
'vitaminB6' => '0.4',
|
||||
'vitaminB12' => '0.5',
|
||||
'vitaminC' => '0.0',
|
||||
'vitaminD' => '0.0',
|
||||
'vitaminE' => '0.2',
|
||||
'vitaminK' => '0.0',
|
||||
'cholecalciferol' => '0.0',
|
||||
'niacin' => '8.0',
|
||||
'riboflavin' => '0.2',
|
||||
'thiamine' => '0.1',
|
||||
'pantothenicAcid' => '1.0',
|
||||
'biotin' => '0.0',
|
||||
'folates' => '10.0',
|
||||
],
|
||||
'carbohydrates_detail' => [
|
||||
'starch' => '0.0',
|
||||
'maltodextrin' => '0.0',
|
||||
'sucrose' => '0.0',
|
||||
'glucose' => '0.0',
|
||||
'lactose' => '0.0',
|
||||
'maltose' => '0.0',
|
||||
'galactose' => '0.0',
|
||||
'carbohydrateHydrates' => '0.0',
|
||||
'boundFructose' => '0.0',
|
||||
'freeFructose' => '0.0',
|
||||
'oligosaccharides' => '0.0',
|
||||
'polyols' => '0.0',
|
||||
'solubleFiber' => '0.0',
|
||||
'inositol' => '0.0',
|
||||
],
|
||||
'fatty_acids' => [
|
||||
'fd' => '0.0',
|
||||
'cholesterol' => '70.0',
|
||||
'transFat' => '0.1',
|
||||
'formic' => '0.0',
|
||||
'acetic' => '0.0',
|
||||
'propionic' => '0.0',
|
||||
'butyric' => '0.0',
|
||||
'valeric' => '0.0',
|
||||
'caproic' => '0.0',
|
||||
'enanthic' => '0.0',
|
||||
'caprylic' => '0.0',
|
||||
'pelargonic' => '0.0',
|
||||
'capric' => '0.0',
|
||||
'undecylic' => '0.0',
|
||||
'lauric' => '0.0',
|
||||
'tridecylic' => '0.0',
|
||||
'myristic' => '0.1',
|
||||
'pentadecylic' => '0.0',
|
||||
'f16d0' => '0.0',
|
||||
'margaric' => '0.0',
|
||||
'stearic' => '0.8',
|
||||
'arachidic' => '0.0',
|
||||
'heneicosylic' => '0.0',
|
||||
'behenic' => '0.0',
|
||||
'tricosylic' => '0.0',
|
||||
'lignoceric' => '0.0',
|
||||
'carboceric' => '0.0',
|
||||
'cerotic' => '0.0',
|
||||
'ceroplastic' => '0.0',
|
||||
'montanic' => '0.0',
|
||||
'nonacosylic' => '0.0',
|
||||
'melissic' => '0.0',
|
||||
'laceric' => '0.0',
|
||||
'hentriacontylic' => '0.0',
|
||||
'hextriacontylic' => '0.0',
|
||||
'heptatriacontylic' => '0.0',
|
||||
'octatriacontylic' => '0.0',
|
||||
'nonadylie' => '0.0',
|
||||
'psyllic' => '0.0',
|
||||
'palmitic' => '1.5',
|
||||
'oleic' => '2.0',
|
||||
'f18d' => '0.0',
|
||||
'f19d' => '0.0',
|
||||
'f11eico' => '0.0',
|
||||
'geddic' => '0.0',
|
||||
'erucic' => '0.0',
|
||||
'nervonic' => '0.0',
|
||||
'hyenic' => '0.0',
|
||||
'amscis' => '0.0',
|
||||
'f18d2cn6' => '0.5',
|
||||
'f18d3n3' => '0.1',
|
||||
'f20d4' => '0.0',
|
||||
'f20d5n3' => '0.0',
|
||||
'f22d6n3' => '0.0',
|
||||
'fapun3' => '0.0',
|
||||
'fapun6' => '0.0',
|
||||
'fapun9' => '0.0',
|
||||
'fapucis' => '0.0',
|
||||
'fapulc' => '0.0',
|
||||
],
|
||||
'amino_acids' => [
|
||||
'essentialAminoAcids' => '8.5',
|
||||
'caseins' => '0.0',
|
||||
'wheyProtein' => '0.0',
|
||||
],
|
||||
'special_compounds' => [
|
||||
'choline' => '60.0',
|
||||
'carnitine' => '5.0',
|
||||
'taurine' => '0.0',
|
||||
'nucleotides' => '0.0',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\ArcadiaBrand;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
|
||||
/**
|
||||
* @extends Factory<IncoSheet>
|
||||
*/
|
||||
final class IncoSheetFactory extends Factory
|
||||
{
|
||||
protected $model = IncoSheet::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) fake()->unique()->numberBetween(10000, 99999),
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'label' => 'Poulet Rôti Classe A',
|
||||
'description' => 'Poulet prêt à cuire élevé en France',
|
||||
'allegations' => [
|
||||
'allegations' => ['Volaille française'],
|
||||
'health' => [],
|
||||
'nutrition' => ['Riche en protéines'],
|
||||
'other' => [],
|
||||
],
|
||||
'sell_arguments' => 'Origine France garantie',
|
||||
'preparation_advices' => 'Cuisson au four 1h à 180°C',
|
||||
'tips' => 'Servir chaud',
|
||||
'sell_familly' => 'Volaille',
|
||||
'ingredients' => [
|
||||
'Ingrédients' => ['Viande de poulet (98%)', 'Sel', 'Epices'],
|
||||
],
|
||||
'portions' => [
|
||||
'lowPart' => 100,
|
||||
'highPart' => 150,
|
||||
'approximative' => false,
|
||||
],
|
||||
'allergens' => [
|
||||
['code' => 1, 'label' => 'Gluten'],
|
||||
],
|
||||
'brand' => [
|
||||
'code' => 1,
|
||||
'label' => 'Le Gaulois',
|
||||
],
|
||||
'is_seasonal' => false,
|
||||
'weight' => [
|
||||
'netWeight' => 1000,
|
||||
'grossWeight' => 1100,
|
||||
'theoreticalAverage' => 1050,
|
||||
],
|
||||
'nutriscore' => [
|
||||
'grade' => 'A',
|
||||
],
|
||||
'storage_condition' => [
|
||||
'instructions' => 'À conserver entre 0°C et 4°C',
|
||||
],
|
||||
'additives' => [
|
||||
['code' => 'E300', 'label' => 'Acide ascorbique'],
|
||||
],
|
||||
'compo_id' => (string) fake()->numberBetween(10000, 99999),
|
||||
];
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (IncoSheet $sheet): void {
|
||||
$raw = is_array($sheet->brand) ? $sheet->brand : [];
|
||||
$code = isset($raw['code']) && is_numeric($raw['code']) ? (int) $raw['code'] : 1;
|
||||
$label = isset($raw['label']) && is_string($raw['label']) ? $raw['label'] : (string) ($raw['libelle'] ?? 'Le Gaulois');
|
||||
|
||||
ArcadiaBrand::query()->firstOrCreate(
|
||||
['code' => $code],
|
||||
['libelle' => $label]
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
if (app()->environment('local', 'testing')) {
|
||||
$schema->dropIfExists('employees');
|
||||
}
|
||||
|
||||
$schema->create('employees', function (Blueprint $table) {
|
||||
$table->string('public_employee_number', 8)->primary();
|
||||
$table->string('last_name');
|
||||
$table->string('first_name');
|
||||
$table->date('start_date');
|
||||
$table->date('end_date')->nullable();
|
||||
$table->date('planned_end_date')->nullable();
|
||||
$table->string('establishment', 20);
|
||||
$table->string('site', 20);
|
||||
$table->string('service', 20);
|
||||
$table->dateTime('created_at')->nullable();
|
||||
$table->dateTime('updated_at')->nullable();
|
||||
|
||||
$table->index('site');
|
||||
$table->index('service');
|
||||
$table->index('establishment');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(Config::string('database.arcadia_meta_model'))
|
||||
->dropIfExists('employees');
|
||||
}
|
||||
};
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
if (app()->environment('local', 'testing')) {
|
||||
$schema->dropIfExists('inco_sheets');
|
||||
}
|
||||
|
||||
$schema->create('inco_sheets', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('label');
|
||||
$table->text('description');
|
||||
$table->json('allegations');
|
||||
$table->text('sell_arguments');
|
||||
$table->text('preparation_advices');
|
||||
$table->text('tips')->nullable();
|
||||
$table->string('sell_familly')->nullable();
|
||||
$table->json('ingredients');
|
||||
$table->json('portions')->nullable();
|
||||
$table->json('allergens');
|
||||
$table->json('brand');
|
||||
$table->boolean('is_seasonal')->default(false);
|
||||
$table->json('weight')->nullable();
|
||||
$table->json('nutriscore')->nullable();
|
||||
$table->json('storage_condition')->nullable();
|
||||
$table->json('additives');
|
||||
$table->string('compo_id')->nullable();
|
||||
$table->dateTime('created_at')->nullable();
|
||||
$table->dateTime('updated_at')->nullable();
|
||||
|
||||
$table->index('name');
|
||||
$table->index('compo_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(Config::string('database.arcadia_meta_model'))
|
||||
->dropIfExists('inco_sheets');
|
||||
}
|
||||
};
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
if (app()->environment('local', 'testing')) {
|
||||
$schema->dropIfExists('inco_compos');
|
||||
}
|
||||
|
||||
$schema->create('inco_compos', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('id_inco');
|
||||
$table->json('identification');
|
||||
$table->json('energy');
|
||||
$table->json('reference_macronutrients');
|
||||
$table->json('portion_macronutrients');
|
||||
$table->json('fresh_produce_and_nuts');
|
||||
$table->json('reference_intakes');
|
||||
$table->json('nutri_score');
|
||||
$table->json('nutri_score_points');
|
||||
$table->json('minerals');
|
||||
$table->json('vitamins');
|
||||
$table->json('carbohydrates_detail');
|
||||
$table->json('fatty_acids');
|
||||
$table->json('amino_acids');
|
||||
$table->json('special_compounds');
|
||||
$table->dateTime('created_at')->nullable();
|
||||
$table->dateTime('updated_at')->nullable();
|
||||
|
||||
$table->index('id_inco');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(Config::string('database.arcadia_meta_model'))
|
||||
->dropIfExists('inco_compos');
|
||||
}
|
||||
};
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
if (app()->environment('local', 'testing')) {
|
||||
$schema->dropIfExists('arcadia_brands');
|
||||
}
|
||||
|
||||
$schema->create('arcadia_brands', function (Blueprint $table) {
|
||||
$table->integer('code')->unsigned()->primary();
|
||||
$table->string('libelle');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
$schema->dropIfExists('arcadia_brands');
|
||||
}
|
||||
};
|
||||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Infra\Database\Models\ArcadiaBrand;
|
||||
use Infra\Database\Models\Brand;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
|
@ -27,11 +26,6 @@ final class BrandSeeder extends Seeder
|
|||
];
|
||||
|
||||
foreach ($brands as $brandData) {
|
||||
ArcadiaBrand::query()->updateOrCreate(
|
||||
['code' => $brandData['code']],
|
||||
['libelle' => $brandData['libelle']],
|
||||
);
|
||||
|
||||
Brand::query()->firstOrCreate(
|
||||
['arcadia_id' => $brandData['code']],
|
||||
[
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ final class DatabaseSeeder extends Seeder
|
|||
{
|
||||
$this->call([
|
||||
EmployeeSeeder::class,
|
||||
IncoSheetSeeder::class,
|
||||
ApiClientSeeder::class,
|
||||
BrandSeeder::class,
|
||||
ArcadiaReplicateSeeder::class,
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Infra\Database\Models\Employee;
|
||||
|
||||
final class EmployeeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$timestamp = now();
|
||||
|
||||
Employee::query()->upsert([
|
||||
[
|
||||
'public_employee_number' => '01155902',
|
||||
'last_name' => 'DOE',
|
||||
'first_name' => 'John',
|
||||
'start_date' => '2024-01-15',
|
||||
'end_date' => null,
|
||||
'planned_end_date' => null,
|
||||
'establishment' => '01',
|
||||
'site' => 'LDCSER',
|
||||
'service' => '097',
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
],
|
||||
[
|
||||
'public_employee_number' => '1234567',
|
||||
'last_name' => 'MARTIN',
|
||||
'first_name' => 'Alice',
|
||||
'start_date' => '2024-01-08',
|
||||
'end_date' => null,
|
||||
'planned_end_date' => null,
|
||||
'establishment' => 'LY',
|
||||
'site' => 'LDCSER',
|
||||
'service' => '101',
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
],
|
||||
[
|
||||
'public_employee_number' => '2345678',
|
||||
'last_name' => 'DUPONT',
|
||||
'first_name' => 'Louis',
|
||||
'start_date' => '2023-05-15',
|
||||
'end_date' => null,
|
||||
'planned_end_date' => '2026-12-31',
|
||||
'establishment' => 'PA',
|
||||
'site' => 'SLELA',
|
||||
'service' => '097',
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
],
|
||||
[
|
||||
'public_employee_number' => '3456789',
|
||||
'last_name' => 'BERNARD',
|
||||
'first_name' => 'Nora',
|
||||
'start_date' => '2022-09-01',
|
||||
'end_date' => null,
|
||||
'planned_end_date' => null,
|
||||
'establishment' => 'BO',
|
||||
'site' => 'DDE',
|
||||
'service' => '205',
|
||||
'created_at' => $timestamp,
|
||||
'updated_at' => $timestamp,
|
||||
],
|
||||
], ['public_employee_number'], [
|
||||
'last_name',
|
||||
'first_name',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'planned_end_date',
|
||||
'establishment',
|
||||
'site',
|
||||
'service',
|
||||
'updated_at',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
|
||||
final class IncoSheetSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed IncoSheet entries (paired with IncoCompo when available, or standalone).
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$sheetDataList = [
|
||||
[
|
||||
'id' => '1',
|
||||
'compo_id' => '1',
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'label' => 'Poulet Rôti aux Herbes',
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'compo_id' => '2',
|
||||
'name' => 'Salade Niçoise 300g',
|
||||
'label' => 'Salade Niçoise',
|
||||
],
|
||||
[
|
||||
'id' => '3',
|
||||
'compo_id' => '3',
|
||||
'name' => 'Lasagnes Bolognaise 400g',
|
||||
'label' => 'Lasagnes Bolognaise',
|
||||
],
|
||||
[
|
||||
'id' => '4',
|
||||
'compo_id' => null,
|
||||
'name' => 'Pain de Mie Brut 500g',
|
||||
'label' => 'Pain de Mie Nature',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($sheetDataList as $data) {
|
||||
if (! IncoSheet::query()->where('id', $data['id'])->exists()) {
|
||||
IncoSheet::factory()->create([
|
||||
'id' => $data['id'],
|
||||
'compo_id' => $data['compo_id'],
|
||||
'name' => $data['name'],
|
||||
'label' => $data['label'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($data['compo_id'] !== null && ! IncoCompo::query()->where('id', $data['compo_id'])->exists()) {
|
||||
IncoCompo::factory()->create([
|
||||
'id' => $data['compo_id'],
|
||||
'id_inco' => $data['compo_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Infra\Database\Models;
|
||||
|
||||
use Database\Factories\ArcadiaBrandFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Infra\Config\ArcadiaStorageConfig;
|
||||
|
||||
/**
|
||||
* @property int $code
|
||||
* @property string $libelle
|
||||
*
|
||||
* @method static \Database\Factories\ArcadiaBrandFactory factory($count = null, $state = [])
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
final class ArcadiaBrand extends Model
|
||||
{
|
||||
/** @use HasFactory<ArcadiaBrandFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): ArcadiaBrandFactory
|
||||
{
|
||||
return ArcadiaBrandFactory::new();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getConnectionName(): string
|
||||
{
|
||||
return resolve(ArcadiaStorageConfig::class)->databaseConnection;
|
||||
}
|
||||
|
||||
protected $table = 'arcadia_brands';
|
||||
|
||||
protected $primaryKey = 'code';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
/** @var string */
|
||||
protected $keyType = 'int';
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
/** @var list<string> */
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'libelle',
|
||||
];
|
||||
|
||||
/** @return array<string, string> */
|
||||
#[\Override]
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'code' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Infra\Database\Models;
|
||||
|
||||
use Database\Factories\EmployeeFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Infra\Casts\UtcDateTimeCast;
|
||||
use Infra\Config\ArcadiaStorageConfig;
|
||||
|
||||
/**
|
||||
* @property string $public_employee_number
|
||||
* @property string $last_name
|
||||
* @property string $first_name
|
||||
* @property \DateTimeImmutable $start_date
|
||||
* @property \DateTimeImmutable|null $end_date
|
||||
* @property \DateTimeImmutable|null $planned_end_date
|
||||
* @property string $establishment
|
||||
* @property string $site
|
||||
* @property string $service
|
||||
* @property \DateTimeImmutable|null $created_at
|
||||
* @property \DateTimeImmutable|null $updated_at
|
||||
*
|
||||
* @method static \Database\Factories\EmployeeFactory factory($count = null, $state = [])
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
final class Employee extends Model
|
||||
{
|
||||
/** @use HasFactory<EmployeeFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): EmployeeFactory
|
||||
{
|
||||
return EmployeeFactory::new();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getConnectionName(): string
|
||||
{
|
||||
return resolve(ArcadiaStorageConfig::class)->databaseConnection;
|
||||
}
|
||||
|
||||
protected $table = 'employees';
|
||||
|
||||
protected $primaryKey = 'public_employee_number';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'public_employee_number',
|
||||
'last_name',
|
||||
'first_name',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'planned_end_date',
|
||||
'establishment',
|
||||
'site',
|
||||
'service',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
/** @return array<string, string> */
|
||||
#[\Override]
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => UtcDateTimeCast::class,
|
||||
'end_date' => UtcDateTimeCast::class,
|
||||
'planned_end_date' => UtcDateTimeCast::class,
|
||||
'created_at' => UtcDateTimeCast::class,
|
||||
'updated_at' => UtcDateTimeCast::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Infra\Database\Models;
|
||||
|
||||
use Database\Factories\IncoCompoFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Infra\Config\ArcadiaStorageConfig;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
* @property string $id_inco
|
||||
* @property array<array-key, mixed> $identification
|
||||
* @property array<array-key, mixed> $energy
|
||||
* @property array<array-key, mixed> $reference_macronutrients
|
||||
* @property array<array-key, mixed> $portion_macronutrients
|
||||
* @property array<array-key, mixed> $fresh_produce_and_nuts
|
||||
* @property array<array-key, mixed> $reference_intakes
|
||||
* @property array<array-key, mixed> $nutri_score
|
||||
* @property array<array-key, mixed> $nutri_score_points
|
||||
* @property array<array-key, mixed> $minerals
|
||||
* @property array<array-key, mixed> $vitamins
|
||||
* @property array<array-key, mixed> $carbohydrates_detail
|
||||
* @property array<array-key, mixed> $fatty_acids
|
||||
* @property array<array-key, mixed> $amino_acids
|
||||
* @property array<array-key, mixed> $special_compounds
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
*
|
||||
* @method static \Database\Factories\IncoCompoFactory factory($count = null, $state = [])
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
final class IncoCompo extends Model
|
||||
{
|
||||
/** @use HasFactory<IncoCompoFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): IncoCompoFactory
|
||||
{
|
||||
return IncoCompoFactory::new();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getConnectionName(): string
|
||||
{
|
||||
return resolve(ArcadiaStorageConfig::class)->databaseConnection;
|
||||
}
|
||||
|
||||
protected $table = 'inco_compos';
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'id_inco',
|
||||
'identification',
|
||||
'energy',
|
||||
'reference_macronutrients',
|
||||
'portion_macronutrients',
|
||||
'fresh_produce_and_nuts',
|
||||
'reference_intakes',
|
||||
'nutri_score',
|
||||
'nutri_score_points',
|
||||
'minerals',
|
||||
'vitamins',
|
||||
'carbohydrates_detail',
|
||||
'fatty_acids',
|
||||
'amino_acids',
|
||||
'special_compounds',
|
||||
];
|
||||
|
||||
/** @return array<string, string> */
|
||||
#[\Override]
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'identification' => 'array',
|
||||
'energy' => 'array',
|
||||
'reference_macronutrients' => 'array',
|
||||
'portion_macronutrients' => 'array',
|
||||
'fresh_produce_and_nuts' => 'array',
|
||||
'reference_intakes' => 'array',
|
||||
'nutri_score' => 'array',
|
||||
'nutri_score_points' => 'array',
|
||||
'minerals' => 'array',
|
||||
'vitamins' => 'array',
|
||||
'carbohydrates_detail' => 'array',
|
||||
'fatty_acids' => 'array',
|
||||
'amino_acids' => 'array',
|
||||
'special_compounds' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Infra\Database\Models;
|
||||
|
||||
use Database\Factories\IncoSheetFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Infra\Config\ArcadiaStorageConfig;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
* @property string $name
|
||||
* @property string $label
|
||||
* @property string $description
|
||||
* @property array<array-key, mixed> $allegations
|
||||
* @property string $sell_arguments
|
||||
* @property string $preparation_advices
|
||||
* @property string|null $tips
|
||||
* @property string|null $sell_familly
|
||||
* @property array<array-key, mixed> $ingredients
|
||||
* @property array<array-key, mixed>|null $portions
|
||||
* @property array<array-key, mixed> $allergens
|
||||
* @property array<array-key, mixed> $brand
|
||||
* @property bool $is_seasonal
|
||||
* @property array<array-key, mixed>|null $weight
|
||||
* @property array<array-key, mixed>|null $nutriscore
|
||||
* @property array<array-key, mixed>|null $storage_condition
|
||||
* @property array<array-key, mixed> $additives
|
||||
* @property string|null $compo_id
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
*
|
||||
* @method static \Database\Factories\IncoSheetFactory factory($count = null, $state = [])
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
final class IncoSheet extends Model
|
||||
{
|
||||
/** @use HasFactory<IncoSheetFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected static function newFactory(): IncoSheetFactory
|
||||
{
|
||||
return IncoSheetFactory::new();
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function getConnectionName(): string
|
||||
{
|
||||
return resolve(ArcadiaStorageConfig::class)->databaseConnection;
|
||||
}
|
||||
|
||||
protected $table = 'inco_sheets';
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'label',
|
||||
'description',
|
||||
'allegations',
|
||||
'sell_arguments',
|
||||
'preparation_advices',
|
||||
'tips',
|
||||
'sell_familly',
|
||||
'ingredients',
|
||||
'portions',
|
||||
'allergens',
|
||||
'brand',
|
||||
'is_seasonal',
|
||||
'weight',
|
||||
'nutriscore',
|
||||
'storage_condition',
|
||||
'additives',
|
||||
'compo_id',
|
||||
];
|
||||
|
||||
/** @return array<string, string> */
|
||||
#[\Override]
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'allegations' => 'array',
|
||||
'ingredients' => 'array',
|
||||
'portions' => 'array',
|
||||
'allergens' => 'array',
|
||||
'brand' => 'array',
|
||||
'is_seasonal' => 'boolean',
|
||||
'weight' => 'array',
|
||||
'nutriscore' => 'array',
|
||||
'storage_condition' => 'array',
|
||||
'additives' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Database\Seeders;
|
||||
|
||||
use Database\Seeders\IncoSheetSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(IncoSheet::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('IncoSheetSeeder Integration Test', function (): void {
|
||||
it('seeds paired IncoSheet and IncoCompo entries including standalone sheets without compo', function (): void {
|
||||
// GIVEN
|
||||
$seeder = new IncoSheetSeeder();
|
||||
|
||||
// WHEN
|
||||
$seeder->run();
|
||||
|
||||
// THEN
|
||||
expect(IncoSheet::count())->toBe(4)
|
||||
->and(IncoCompo::count())->toBe(3)
|
||||
->and(IncoSheet::query()->whereNull('compo_id')->count())->toBe(1);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue