Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Programs\Database\Factories;
|
||||
|
||||
use Functional\Programs\Models\Program;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Program>
|
||||
*/
|
||||
class ProgramFactory extends Factory
|
||||
{
|
||||
protected $model = Program::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->randomElement([
|
||||
'Prise de masse 8 semaines', 'Sèche été', 'Préparation force',
|
||||
'Remise en forme progressive', 'Cross-training intensif', 'Retour de blessure',
|
||||
]) . ' ' . 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(15) : null,
|
||||
'duration_weeks' => fake()->numberBetween(4, 16),
|
||||
'days_per_week' => fake()->optional(0.8)->numberBetween(2, 6),
|
||||
'is_public' => fake()->boolean(25),
|
||||
];
|
||||
}
|
||||
|
||||
/** Programme partagé publiquement (visible du catalogue communautaire). */
|
||||
public function public(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['is_public' => true]);
|
||||
}
|
||||
|
||||
/** Programme privé, réservé à son propriétaire. */
|
||||
public function private(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => ['is_public' => false]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Programs\Database\Factories;
|
||||
|
||||
use Functional\Programs\Models\Program;
|
||||
use Functional\Programs\Models\ProgramSlot;
|
||||
use Functional\Routines\Models\Routine;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<ProgramSlot>
|
||||
*/
|
||||
class ProgramSlotFactory extends Factory
|
||||
{
|
||||
protected $model = ProgramSlot::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'program_id' => Program::factory(),
|
||||
'week' => fake()->numberBetween(1, 8),
|
||||
'weekday' => fake()->numberBetween(1, 7),
|
||||
'routine_id' => fake()->boolean(85) ? Routine::factory() : null,
|
||||
'label' => fake()->optional(0.3)->randomElement(['Repos actif', 'Séance test', 'Deload']),
|
||||
];
|
||||
}
|
||||
|
||||
/** Case de repos, sans routine associée. */
|
||||
public function restDay(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'routine_id' => null,
|
||||
'label' => 'Repos',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user