20-02-2026

This commit is contained in:
Kevin Adametz 2026-02-20 17:57:50 +01:00
parent 854ce02bf6
commit 4d6b4930b2
128 changed files with 18247 additions and 2093 deletions

View file

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\Brand;
use App\Models\Partner;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Brand>
*/
class BrandFactory extends Factory
{
protected $model = Brand::class;
public function definition(): array
{
$name = fake()->company().' '.fake()->randomElement(['Design', 'Living', 'Home']);
return [
'partner_id' => Partner::factory()->manufacturer(),
'name' => $name,
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(100, 999),
'is_active' => true,
];
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @template TModel of \App\Models\Category
*
* @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel>
*/
class CategoryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var class-string<TModel>
*/
protected $model = Category::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->unique()->word(),
'slug' => fake()->unique()->slug(2),
'description' => fake()->sentence(),
];
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Models\Hub;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Hub>
*/
class HubFactory extends Factory
{
protected $model = Hub::class;
public function definition(): array
{
$name = fake()->city().' '.fake()->randomElement(['Region', 'Hub', 'Gebiet']);
return [
'name' => $name,
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(100, 999),
'is_active' => true,
];
}
/**
* Inaktiver Hub.
*/
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace Database\Factories;
use App\Models\Media;
use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Media>
*/
class MediaFactory extends Factory
{
protected $model = Media::class;
public function definition(): array
{
return [
'model_type' => Product::class,
'model_id' => Product::factory(),
'file_path' => 'media/'.fake()->uuid().'.jpg',
'type' => 'image',
'alt_text' => fake()->sentence(3),
'order_column' => 0,
];
}
/**
* Video-Media.
*/
public function video(): static
{
return $this->state(fn (array $attributes) => [
'type' => 'video',
'file_path' => 'media/'.fake()->uuid().'.mp4',
]);
}
/**
* PDF-Dokument.
*/
public function pdf(): static
{
return $this->state(fn (array $attributes) => [
'type' => 'pdf',
'file_path' => 'media/'.fake()->uuid().'.pdf',
]);
}
}

View file

@ -0,0 +1,79 @@
<?php
namespace Database\Factories;
use App\Models\Partner;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Partner>
*/
class PartnerFactory extends Factory
{
protected $model = Partner::class;
public function definition(): array
{
$company = fake()->company();
return [
'company_name' => $company,
'slug' => Str::slug($company).'-'.fake()->unique()->numberBetween(100, 999),
'type' => 'Retailer',
'is_active' => true,
];
}
/**
* Händler (Retailer).
*/
public function retailer(): static
{
return $this->state(fn (array $attributes) => [
'type' => 'Retailer',
'delivery_radius_km' => fake()->numberBetween(10, 100),
]);
}
/**
* Hersteller (Manufacturer).
*/
public function manufacturer(): static
{
return $this->state(fn (array $attributes) => [
'type' => 'Manufacturer',
]);
}
/**
* Makler (Estate-Agent).
*/
public function estateAgent(): static
{
return $this->state(fn (array $attributes) => [
'type' => 'Estate-Agent',
]);
}
/**
* Partner mit Setup abgeschlossen.
*/
public function setupCompleted(): static
{
return $this->state(fn (array $attributes) => [
'setup_completed' => true,
'setup_completed_at' => now(),
]);
}
/**
* Inaktiver Partner.
*/
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Product;
use App\Models\ProductActivity;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<ProductActivity>
*/
class ProductActivityFactory extends Factory
{
protected $model = ProductActivity::class;
public function definition(): array
{
return [
'product_id' => Product::factory(),
'user_id' => User::factory(),
'action' => fake()->randomElement(['created', 'updated', 'submitted', 'approved', 'correction', 'rejected']),
'note' => null,
];
}
}

View file

@ -0,0 +1,93 @@
<?php
namespace Database\Factories;
use App\Enums\PriceType;
use App\Enums\ProductStatus;
use App\Enums\ProductType;
use App\Models\Hub;
use App\Models\Partner;
use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Product>
*/
class ProductFactory extends Factory
{
protected $model = Product::class;
public function definition(): array
{
$name = fake()->words(3, true);
return [
'partner_id' => Partner::factory(),
'name' => ucfirst($name),
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(1000, 9999),
'product_type' => ProductType::LocalStock,
'status' => ProductStatus::Draft,
'price_type' => PriceType::Fixed,
'description_short' => fake()->sentence(),
'description_long' => fake()->paragraphs(2, true),
'is_curated' => false,
'is_available' => true,
];
}
/**
* Teaser-Produkt (Säule A: Local Express).
*/
public function localStock(): static
{
return $this->state(fn (array $attributes) => [
'product_type' => ProductType::LocalStock,
'price_type' => PriceType::Fixed,
]);
}
/**
* Konfigurations-Produkt (Säule B: Smart Club).
*/
public function smartOrder(): static
{
return $this->state(fn (array $attributes) => [
'product_type' => ProductType::SmartOrder,
'price_type' => PriceType::FromPrice,
]);
}
/**
* Aktives und kuratiertes Produkt.
*/
public function active(): static
{
return $this->state(fn (array $attributes) => [
'status' => ProductStatus::Active,
'is_curated' => true,
'curated_at' => now(),
]);
}
/**
* Produkt in einem bestimmten Hub.
*/
public function inHub(Hub $hub): static
{
return $this->state(fn (array $attributes) => [
'hub_id' => $hub->id,
]);
}
/**
* Verkauftes Produkt.
*/
public function sold(): static
{
return $this->state(fn (array $attributes) => [
'status' => ProductStatus::Sold,
'is_available' => false,
]);
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Models\Product;
use App\Models\ProductWoodOrigin;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<ProductWoodOrigin>
*/
class ProductWoodOriginFactory extends Factory
{
protected $model = ProductWoodOrigin::class;
public function definition(): array
{
return [
'product_id' => Product::factory(),
'wood_species' => fake()->randomElement(['Quercus robur', 'Fagus sylvatica', 'Pinus sylvestris', 'Picea abies']),
'origin_country' => fake()->randomElement(['DE', 'AT', 'PL', 'CZ', 'FR']),
'origin_region' => fake()->optional()->city(),
'harvest_year' => fake()->optional()->numberBetween(2020, 2026),
'forest_operator' => fake()->optional()->company(),
'sustainability_certificate' => fake()->optional()->randomElement(['FSC', 'PEFC', 'FSC/PEFC']),
'eudr_reference_id' => fake()->optional()->uuid(),
];
}
}