Build & Deploy / build (push) Successful in 18s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Functional\Routines\Database\Factories;
|
|
|
|
use Functional\Routines\Models\Routine;
|
|
use Functional\Users\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Routine>
|
|
*/
|
|
class RoutineFactory extends Factory
|
|
{
|
|
protected $model = Routine::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->randomElement([
|
|
'Full body débutant', 'Push day', 'Pull day', 'Leg day', 'Upper body',
|
|
'Circuit HIIT', 'Force 5x5', 'Hypertrophie bras', 'Core & mobilité',
|
|
]) . ' ' . fake()->numberBetween(1, 9);
|
|
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'name' => $name,
|
|
'slug' => Str::slug($name) . '-' . fake()->unique()->numberBetween(1000, 9999),
|
|
'description' => fake()->boolean(70) ? fake()->sentence(12) : null,
|
|
'is_public' => fake()->boolean(30),
|
|
'estimated_minutes' => fake()->optional(0.8)->numberBetween(20, 90),
|
|
];
|
|
}
|
|
|
|
/** Routine partagée publiquement (visible du catalogue communautaire). */
|
|
public function public(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => ['is_public' => true]);
|
|
}
|
|
|
|
/** Routine privée, réservée à son propriétaire. */
|
|
public function private(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => ['is_public' => false]);
|
|
}
|
|
}
|