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,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,
]);
}
}