Files
Caramel-CRM/database/factories/LineItemFactory.php
T

27 lines
810 B
PHP
Raw Normal View History

2025-10-20 08:57:51 +02:00
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
2025-11-26 10:05:43 +01:00
use App\Models\Unit;
2025-10-20 08:57:51 +02:00
class LineItemFactory extends Factory
{
public function definition(): array
{
$isSection = rand(0, 10) > 7;
2025-12-04 22:37:16 +01:00
$unit = Unit::where('name', $this->faker->randomElement(['Stück', 'Stunden', 'Tage', 'pauschal']))->first();
2025-10-20 08:57:51 +02:00
return [
'position' => $this->faker->numberBetween(1, 10) + ($isSection ? 0.5 : 0),
'is_section' => $isSection,
2025-10-20 08:57:51 +02:00
'title' => $this->faker->words(3, true),
'description' => $this->faker->sentence(),
'quantity' => $this->faker->numberBetween(1, 10),
2025-12-04 22:37:16 +01:00
'unit_id' => $unit ? $unit->id : null,
2025-10-20 08:57:51 +02:00
'price' => $this->faker->randomFloat(2, 10, 500),
];
}
}