fix: 🗃️ update/clean existing seeders
This commit is contained in:
parent
d5a40041ca
commit
b089dd66dc
19 changed files with 504 additions and 206 deletions
|
|
@ -298,40 +298,6 @@ class Document extends Model implements TranslatableModel
|
|||
return $data;
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Relation to Tag
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function tags(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->morphedByMany(
|
||||
DocumentTag::class,
|
||||
'documentable',
|
||||
'documentables',
|
||||
'document_id',
|
||||
'documentable_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation to Category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->morphedByMany(
|
||||
DocumentCategory::class,
|
||||
'documentable',
|
||||
'documentables',
|
||||
'document_id',
|
||||
'documentable_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
public function inertiaFill(array $attributes)
|
||||
{
|
||||
// j'extrait issuPath et j'applique un traitement ensuite.
|
||||
|
|
@ -370,4 +336,38 @@ class Document extends Model implements TranslatableModel
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Relation to Tag
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function tags(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->morphedByMany(
|
||||
DocumentTag::class,
|
||||
'documentable',
|
||||
'documentables',
|
||||
'document_id',
|
||||
'documentable_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relation to Category
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function categories(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->morphedByMany(
|
||||
DocumentCategory::class,
|
||||
'documentable',
|
||||
'documentables',
|
||||
'document_id',
|
||||
'documentable_id'
|
||||
)->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
database/factories/CompanyActivityFactory.php
Normal file
29
database/factories/CompanyActivityFactory.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CompanyActivity>
|
||||
*/
|
||||
class CompanyActivityFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"name" => $this->faker->unique()->words(
|
||||
$this->faker->numberBetween(3, 4),
|
||||
true
|
||||
),
|
||||
"color" => $this->faker->hexColor(),
|
||||
"published" => $this->faker->boolean(50),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,9 @@ use App\Models\CompanySector;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Company>
|
||||
*/
|
||||
class CompanyFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
|
@ -21,7 +24,7 @@ class CompanyFactory extends Factory
|
|||
$companySectorModel = fake()->randomElement(CompanySector::all());
|
||||
|
||||
return [
|
||||
'name' => fake()->company(),
|
||||
'name' => fake()->unique()->company(),
|
||||
'responsable' => fake()->name(),
|
||||
'informations' => fake()->text(200),
|
||||
'latitude' => fake()->latitude(),
|
||||
|
|
|
|||
28
database/factories/CompanySectorFactory.php
Normal file
28
database/factories/CompanySectorFactory.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CompanySector>
|
||||
*/
|
||||
class CompanySectorFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
"name" => $this->faker->unique()->words(
|
||||
$this->faker->numberBetween(3, 4),
|
||||
true
|
||||
),
|
||||
"published" => $this->faker->boolean(50),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DocumentCategory>
|
||||
|
|
@ -16,8 +17,12 @@ class DocumentCategoryFactory extends Factory
|
|||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->word();
|
||||
$slug = Str::slug($name);
|
||||
|
||||
return [
|
||||
'name' => $this->faker->unique()->word(),
|
||||
'name' => $name,
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,42 +10,23 @@ use App\Models\DocumentTag;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Document>
|
||||
*/
|
||||
class DocumentFactory extends Factory
|
||||
{
|
||||
protected $model = Document::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$title = $this->faker->sentence(3);
|
||||
return [
|
||||
'name' => $title,
|
||||
'path' => 'documents/' . Str::slug($title) . '.pdf',
|
||||
'exercice' => $this->faker->randomElement(YearsEnum::cases()),
|
||||
'status' => $this->faker->randomElement(DocumentStatusEnum::cases()),
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
|
||||
'unpublished_at' => null,
|
||||
'name' => $this->faker->sentence(3),
|
||||
'exercice' => $this->faker->randomElement(YearsEnum::cases()),
|
||||
'status' => $this->faker->randomElement(DocumentStatusEnum::cases()),
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute automatiquement des tags à un document créé.
|
||||
*/
|
||||
public function withTags(int $count = 3): static
|
||||
{
|
||||
return $this->afterCreating(function (Document $document) use ($count) {
|
||||
$tags = DocumentTag::factory()->count($count)->create();
|
||||
$document->tags()->sync($tags->pluck('id'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajoute automatiquement des tags à un document créé.
|
||||
*/
|
||||
public function withCategories(int $count = 3): static
|
||||
{
|
||||
return $this->afterCreating(function (Document $document) use ($count) {
|
||||
$cats = DocumentCategory::factory()->count($count)->create();
|
||||
$document->categories()->sync($cats->pluck('id'));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,27 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\DocumentTag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DocumentTag>
|
||||
*/
|
||||
class DocumentTagFactory extends Factory
|
||||
{
|
||||
protected $model = DocumentTag::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->word();
|
||||
$slug = Str::slug($name);
|
||||
|
||||
return [
|
||||
'name' => $this->faker->unique()->word(),
|
||||
'name' => $name,
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ use App\Models\PageConfig;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\DynamicPage>
|
||||
*/
|
||||
class DynamicPageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\News>
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\NewsCategory>
|
||||
*/
|
||||
class NewsCategoryFactory extends Factory
|
||||
{
|
||||
|
|
@ -16,9 +17,12 @@ class NewsCategoryFactory extends Factory
|
|||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->word();
|
||||
$slug = Str::slug($name);
|
||||
|
||||
return [
|
||||
"name" => $this->faker->unique()->word(),
|
||||
"slug" => $this->faker->unique()->word(),
|
||||
"name" => $name,
|
||||
"slug" => $slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\NewsTag>
|
||||
|
|
@ -16,10 +17,13 @@ class NewsTagFactory extends Factory
|
|||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->unique()->word();
|
||||
$slug = Str::slug($name);
|
||||
|
||||
return [
|
||||
"name" => $this->faker->unique()->word(),
|
||||
"slug" => $this->faker->unique()->word(),
|
||||
"color" => "#fff"
|
||||
"name" => $name,
|
||||
"slug" => $slug,
|
||||
"color" => $this->faker->hexColor(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@ use App\Models\PageConfig;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PageConfig>
|
||||
*/
|
||||
class PageConfigFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
|
|
|
|||
19
database/seeders/CompanyActivitySeeder.php
Normal file
19
database/seeders/CompanyActivitySeeder.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CompanyActivity;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CompanyActivitySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
CompanyActivity::factory(10)->create();
|
||||
}
|
||||
}
|
||||
19
database/seeders/CompanySectorSeeder.php
Normal file
19
database/seeders/CompanySectorSeeder.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CompanySector;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CompanySectorSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
CompanySector::factory(10)->create();
|
||||
}
|
||||
}
|
||||
282
database/seeders/CustomSeeder.php
Normal file
282
database/seeders/CustomSeeder.php
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\CompanyActivity;
|
||||
use App\Models\CompanySector;
|
||||
use App\Models\DocumentCategory;
|
||||
use App\Models\DocumentTag;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class CustomSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// php artisan db:seed --class=CustomSeeder
|
||||
$this->companyActivitySeeder();
|
||||
$this->companySectorSeeder();
|
||||
$this->documentCategorySeeder();
|
||||
$this->documentTagSeeder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom company activity seeder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function companyActivitySeeder(): void
|
||||
{
|
||||
// Set FR values.
|
||||
app()->setLocale("fr");
|
||||
$firstActivity = CompanyActivity::create([
|
||||
"name" => "Amont",
|
||||
"color" => "#6fbc45",
|
||||
"published" => 1,
|
||||
]);
|
||||
$secondActivity = CompanyActivity::create([
|
||||
"name" => "International",
|
||||
"color" => "#b24881",
|
||||
"published" => 1,
|
||||
]);
|
||||
$thirdActivity = CompanyActivity::create([
|
||||
"name" => "Plateformes",
|
||||
"color" => "#6d6d6d",
|
||||
"published" => 1,
|
||||
]);
|
||||
$fourthActivity = CompanyActivity::create([
|
||||
"name" => "Traiteur",
|
||||
"color" => "#f29100",
|
||||
"published" => 1,
|
||||
]);
|
||||
$fifthActivity = CompanyActivity::create([
|
||||
"name" => "Volaille",
|
||||
"color" => "#DC2034",
|
||||
"published" => 1,
|
||||
]);
|
||||
|
||||
// Set EN values.
|
||||
app()->setLocale("en");
|
||||
$firstActivity->update([
|
||||
"name" => "Upstream",
|
||||
]);
|
||||
$secondActivity->update([
|
||||
"name" => "International",
|
||||
]);
|
||||
$thirdActivity->update([
|
||||
"name" => "Platforms",
|
||||
]);
|
||||
$fourthActivity->update([
|
||||
"name" => "Catering",
|
||||
]);
|
||||
$fifthActivity->update([
|
||||
"name" => "Poultry",
|
||||
]);
|
||||
|
||||
// Set locale to the fallback.
|
||||
app()->setLocale(config('app.fallback_locale'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom company sector seeder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function companySectorSeeder(): void
|
||||
{
|
||||
collect([
|
||||
"Allemagne - ECF - Clements BETTERMANN",
|
||||
"Angleterre - Capestone - Rob Cumine",
|
||||
"Belgique - Kiplama - Toon KWEENS",
|
||||
"Hongrie et Roumanie - Ákos Szabó",
|
||||
"Pologne - Adam Sojka",
|
||||
"Pôle Amont - Filière Céréales - Gaël Le Conte",
|
||||
"Pôle Amont - Filière Oeufs - Christophe Bériard",
|
||||
"Pôle Amont - Filière Spécialités - Didier Richard",
|
||||
"Pôle Amont - Filière Vif - Stéphane Landreau",
|
||||
"Pôle Amont - Filière accouvage - Olivier Sionneau",
|
||||
"Pôle Traiteur - Crêpes et galettes - Christèle Lucas",
|
||||
"Pôle Traiteur - La Toque Angevine - Pierre Lonjon",
|
||||
"Pôle Traiteur - Pizzas, tartes, sandwiches et quiches - Yann Gomez",
|
||||
"Pôle Traiteur - Plats cuisinés : Marie, Traditions d’Asie, Weight Watchers - Guillaume LETENNEUR",
|
||||
"Pôle Traiteur - Plats cuisinés et produits exotiques - Benjamin Montlahuc",
|
||||
"Pôle Traiteur - Restauration Hors Domicile - Ludovic Courtier",
|
||||
"Pôle Traiteur - Surgelés - Didier Gand",
|
||||
"Pôle Volaille - Cailles Robin - Guy Prod’homme",
|
||||
"Pôle Volaille - GPA Distribution Paris - Thierry Lambert",
|
||||
"Pôle Volaille - Hauts de France",
|
||||
"Pôle Volaille - LDC Aquitaine - Denis Bordes",
|
||||
"Pôle Volaille - LDC Foods - Mickaël Rio",
|
||||
"Pôle Volaille - LDC TERRAVENIR - Christophe Pajot",
|
||||
"Pôle Volaille - PFC - Dominique Théreau",
|
||||
"Pôle Volaille - Société Arrivé - Roland Tonarelli",
|
||||
"Pôle Volaille - Société Bretonne de Volaille - Laurent Girard",
|
||||
"Pôle Volaille - Société Favreau Couthouis - Roland Tonarelli",
|
||||
"Pôle Volaille - VOLENA - Arnaud Boinard",
|
||||
"Pôle volaille - Pôle VDR - Philippe Aubert",
|
||||
])->map(function (string $sector) {
|
||||
CompanySector::create([
|
||||
"name" => $sector,
|
||||
"published" => 1,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom document category seeder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function documentCategorySeeder(): void
|
||||
{
|
||||
// Set FR values.
|
||||
app()->setLocale("fr");
|
||||
$docs = DocumentCategory::create([
|
||||
"name" => "Documents",
|
||||
"slug" => "documents"
|
||||
]);
|
||||
$meetings = DocumentCategory::create([
|
||||
"name" => "Assemblées générales",
|
||||
"slug" => "assemblees-generales"
|
||||
]);
|
||||
$investors = DocumentCategory::create([
|
||||
"name" => "Présentation investisseurs",
|
||||
"slug" => "presentation-investisseurs"
|
||||
]);
|
||||
$press = DocumentCategory::create([
|
||||
"name" => "Espace presse",
|
||||
"slug" => "espace-presse"
|
||||
]);
|
||||
|
||||
// Set EN values.
|
||||
app()->setLocale("en");
|
||||
$docs->update([
|
||||
"name" => "Documents",
|
||||
"slug" => "documents"
|
||||
]);
|
||||
$meetings->update([
|
||||
"name" => "General meetings",
|
||||
"slug" => "general-meetings"
|
||||
]);
|
||||
$investors->update([
|
||||
"name" => "Investor presentation",
|
||||
"slug" => "investor-presentation"
|
||||
]);
|
||||
$press->update([
|
||||
"name" => "Meetings Press area",
|
||||
"slug" => "meeting-press-area"
|
||||
]);
|
||||
|
||||
// Set locale to the fallback.
|
||||
app()->setLocale(config('app.fallback_locale'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom document tag seeder.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function documentTagSeeder(): void
|
||||
{
|
||||
// Set FR values.
|
||||
app()->setLocale("fr");
|
||||
$communique = DocumentTag::create([
|
||||
"name" => "Communiqués et Avis financiers",
|
||||
"slug" => "communiques-et-avis-financiers"
|
||||
]);
|
||||
$semestriel = DocumentTag::create([
|
||||
"name" => "Rapports financiers annuels et semestriels",
|
||||
"slug" => "rapports-financiers-annuels-et-semestriels"
|
||||
]);
|
||||
$droitdevote = DocumentTag::create([
|
||||
"name" => "Déclaration mensuelles du nombre d’actions et de droits de vote",
|
||||
"slug" => "declaration-mensuelles-du-nombre-dactions-et-de-droits-de-vote"
|
||||
]);
|
||||
$rachat = DocumentTag::create([
|
||||
"name" => "Descriptif de programme de rachats d’actions",
|
||||
"slug" => "descriptif-de-programme-de-rachats-dactions"
|
||||
]);
|
||||
$liquidite = DocumentTag::create([
|
||||
"name" => "Opérations sur contrat de liquidité",
|
||||
"slug" => "operations-sur-contrat-de-liquidite"
|
||||
]);
|
||||
$trimestriel = DocumentTag::create([
|
||||
"name" => "Information Trimestrielle",
|
||||
"slug" => "information-trimestrielle"
|
||||
]);
|
||||
$publication = DocumentTag::create([
|
||||
"name" => "Publication",
|
||||
"slug" => "publication"
|
||||
]);
|
||||
$finance = DocumentTag::create([
|
||||
"name" => "Finance",
|
||||
"slug" => "finance"
|
||||
]);
|
||||
$general = DocumentTag::create([
|
||||
"name" => "Assemblée générale des actionnaires",
|
||||
"slug" => "assemblee-generale-des-actionnaires"
|
||||
]);
|
||||
$declaration = DocumentTag::create([
|
||||
"name" => "Déclaration des rachats d’actions",
|
||||
"slug" => "declaration-des-rachats-dactions"
|
||||
]);
|
||||
$statuts = DocumentTag::create([
|
||||
"name" => "Statuts de la SA LDC",
|
||||
"slug" => "statuts-de-la-sa-ldc"
|
||||
]);
|
||||
|
||||
// Set EN values.
|
||||
app()->setLocale("en");
|
||||
$communique->update([
|
||||
"name" => "Press releases and financial notices",
|
||||
"slug" => "communiques-et-avis-financiers-en"
|
||||
]);
|
||||
$semestriel->update([
|
||||
"name" => "Annual and half-yearly financial reports",
|
||||
"slug" => "rapports-financiers-annuels-et-semestriels-en"
|
||||
]);
|
||||
$droitdevote->update([
|
||||
"name" => "Monthly declaration of the number of shares and voting rights",
|
||||
"slug" => "declaration-mensuelles-du-nombre-dactions-et-de-droits-de-vote-en"
|
||||
]);
|
||||
$rachat->update([
|
||||
"name" => "Description of share buyback program",
|
||||
"slug" => "descriptif-de-programme-de-rachats-dactions-en"
|
||||
]);
|
||||
$liquidite->update([
|
||||
"name" => "Liquidity contract transactions",
|
||||
"slug" => "operations-sur-contrat-de-liquidite-en"
|
||||
]);
|
||||
$trimestriel->update([
|
||||
"name" => "Quarterly Information",
|
||||
"slug" => "information-trimestrielle-en"
|
||||
]);
|
||||
$publication->update([
|
||||
"name" => "Publication",
|
||||
"slug" => "publication-en"
|
||||
]);
|
||||
$finance->update([
|
||||
"name" => "Finance",
|
||||
"slug" => "finance-en"
|
||||
]);
|
||||
$general->update([
|
||||
"name" => "General Meeting of Shareholders",
|
||||
"slug" => "assemblee-generale-des-actionnaires-en"
|
||||
]);
|
||||
$declaration->update([
|
||||
"name" => "Declaration of share buybacks",
|
||||
"slug" => "declaration-des-rachats-dactions-en"
|
||||
]);
|
||||
$statuts->update([
|
||||
"name" => "Statutes of SA LDC",
|
||||
"slug" => "statuts-de-la-sa-ldc-en"
|
||||
]);
|
||||
|
||||
// Set locale to the fallback.
|
||||
app()->setLocale(config('app.fallback_locale'));
|
||||
}
|
||||
}
|
||||
|
|
@ -21,8 +21,14 @@ class DatabaseSeeder extends Seeder
|
|||
PageConfigSeeder::class,
|
||||
DynamicPageSeeder::class,
|
||||
NewsCategorySeeder::class,
|
||||
NewsTagSeeder::class,
|
||||
NewsSeeder::class,
|
||||
CompanyActivitySeeder::class,
|
||||
CompanySectorSeeder::class,
|
||||
CompanySeeder::class,
|
||||
DocumentCategorySeeder::class,
|
||||
DocumentTagSeeder::class,
|
||||
DocumentSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,43 +9,11 @@ class DocumentCategorySeeder extends Seeder
|
|||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
app()->setLocale("fr");
|
||||
$docs = DocumentCategory::create([
|
||||
"name" => "Documents", // pour finance
|
||||
"slug" => "documents"
|
||||
]);
|
||||
$meetings = DocumentCategory::create([
|
||||
"name" => "Assemblées générales", // pour finance
|
||||
"slug" => "assemblees-generales"
|
||||
]);
|
||||
$investors = DocumentCategory::create([
|
||||
"name" => "Présentation investisseurs", // pour finance
|
||||
"slug" => "presentation-investisseurs"
|
||||
]);
|
||||
$press = DocumentCategory::create([
|
||||
"name" => "Espace presse",
|
||||
"slug" => "espace-presse"
|
||||
]);
|
||||
|
||||
app()->setLocale("en");
|
||||
$docs->update([
|
||||
"name" => "Documents",
|
||||
"slug" => "documents"
|
||||
]);
|
||||
$meetings->update([
|
||||
"name" => "General meetings",
|
||||
"slug" => "general-meetings"
|
||||
]);
|
||||
$investors->update([
|
||||
"name" => "Investor presentation",
|
||||
"slug" => "investor-presentation"
|
||||
]);
|
||||
$press->update([
|
||||
"name" => "Meetings Press area",
|
||||
"slug" => "meeting-press-area"
|
||||
]);
|
||||
DocumentCategory::factory(10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\DocumentCategory;
|
||||
use App\Models\DocumentTag;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Uwil\LaravelCommon\Helpers\FileHelper;
|
||||
|
||||
|
|
@ -10,11 +12,12 @@ class DocumentSeeder extends Seeder
|
|||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Document::factory(3)->withTags(3)->withCategories(2)->make()
|
||||
->each(function ($model) {
|
||||
Document::factory(3)->make()->each(function (Document $model) {
|
||||
$model->path = FileHelper::storeFile(
|
||||
$model,
|
||||
new \SplFileInfo(\resource_path(
|
||||
|
|
@ -22,6 +25,22 @@ class DocumentSeeder extends Seeder
|
|||
))
|
||||
);
|
||||
$model->saveOrFail();
|
||||
});;
|
||||
});
|
||||
|
||||
// Document categories relation.
|
||||
$categoriesIds = DocumentCategory::pluck('id');
|
||||
Document::query()->get()->map(function (Document $document) use ($categoriesIds) {
|
||||
$document->categories()->attach(
|
||||
$categoriesIds->random(rand(1, 3))->all()
|
||||
);
|
||||
});
|
||||
|
||||
// Document tags relation.
|
||||
$tagsIds = DocumentTag::pluck('id');
|
||||
Document::query()->get()->map(function (Document $document) use ($tagsIds) {
|
||||
$document->tags()->attach(
|
||||
$tagsIds->random(rand(1, 3))->all()
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,98 +9,11 @@ class DocumentTagSeeder extends Seeder
|
|||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
app()->setLocale("fr");
|
||||
$communique = DocumentTag::create([
|
||||
"name" => "Communiqués et Avis financiers",
|
||||
"slug" => "communiques-et-avis-financiers"
|
||||
]);
|
||||
$semestriel = DocumentTag::create([
|
||||
"name" => "Rapports financiers annuels et semestriels",
|
||||
"slug" => "rapports-financiers-annuels-et-semestriels"
|
||||
]);
|
||||
$droitdevote = DocumentTag::create([
|
||||
"name" => "Déclaration mensuelles du nombre d’actions et de droits de vote",
|
||||
"slug" => "declaration-mensuelles-du-nombre-dactions-et-de-droits-de-vote"
|
||||
]);
|
||||
$rachat = DocumentTag::create([
|
||||
"name" => "Descriptif de programme de rachats d’actions",
|
||||
"slug" => "descriptif-de-programme-de-rachats-dactions"
|
||||
]);
|
||||
$liquidite = DocumentTag::create([
|
||||
"name" => "Opérations sur contrat de liquidité",
|
||||
"slug" => "operations-sur-contrat-de-liquidite"
|
||||
]);
|
||||
$trimestriel = DocumentTag::create([
|
||||
"name" => "Information Trimestrielle",
|
||||
"slug" => "information-trimestrielle"
|
||||
]);
|
||||
$publication = DocumentTag::create([
|
||||
"name" => "Publication",
|
||||
"slug" => "publication"
|
||||
]);
|
||||
$finance = DocumentTag::create([
|
||||
"name" => "Finance",
|
||||
"slug" => "finance"
|
||||
]);
|
||||
$general = DocumentTag::create([
|
||||
"name" => "Assemblée générale des actionnaires",
|
||||
"slug" => "assemblee-generale-des-actionnaires"
|
||||
]);
|
||||
$declaration = DocumentTag::create([
|
||||
"name" => "Déclaration des rachats d’actions",
|
||||
"slug" => "declaration-des-rachats-dactions"
|
||||
]);
|
||||
$statuts = DocumentTag::create([
|
||||
"name" => "Statuts de la SA LDC",
|
||||
"slug" => "statuts-de-la-sa-ldc"
|
||||
]);
|
||||
app()->setLocale("en");
|
||||
$communique->update([
|
||||
"name" => "Press releases and financial notices",
|
||||
"slug" => "communiques-et-avis-financiers-en"
|
||||
]);
|
||||
$semestriel->update([
|
||||
"name" => "Annual and half-yearly financial reports",
|
||||
"slug" => "rapports-financiers-annuels-et-semestriels-en"
|
||||
]);
|
||||
$droitdevote->update([
|
||||
"name" => "Monthly declaration of the number of shares and voting rights",
|
||||
"slug" => "declaration-mensuelles-du-nombre-dactions-et-de-droits-de-vote-en"
|
||||
]);
|
||||
$rachat->update([
|
||||
"name" => "Description of share buyback program",
|
||||
"slug" => "descriptif-de-programme-de-rachats-dactions-en"
|
||||
]);
|
||||
$liquidite->update([
|
||||
"name" => "Liquidity contract transactions",
|
||||
"slug" => "operations-sur-contrat-de-liquidite-en"
|
||||
]);
|
||||
$trimestriel->update([
|
||||
"name" => "Quarterly Information",
|
||||
"slug" => "information-trimestrielle-en"
|
||||
]);
|
||||
$publication->update([
|
||||
"name" => "Publication",
|
||||
"slug" => "publication-en"
|
||||
]);
|
||||
$finance->update([
|
||||
"name" => "Finance",
|
||||
"slug" => "finance-en"
|
||||
]);
|
||||
$general->update([
|
||||
"name" => "General Meeting of Shareholders",
|
||||
"slug" => "assemblee-generale-des-actionnaires-en"
|
||||
]);
|
||||
$declaration->update([
|
||||
"name" => "Declaration of share buybacks",
|
||||
"slug" => "declaration-des-rachats-dactions-en"
|
||||
]);
|
||||
$statuts->update([
|
||||
"name" => "Statutes of SA LDC",
|
||||
"slug" => "statuts-de-la-sa-ldc-en"
|
||||
]);
|
||||
DocumentTag::factory(10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class NewsTagSeeder extends Seeder
|
|||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue