Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Database\Factories;
|
||||
|
||||
use Functional\Streaks\Models\Achievement;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Achievement>
|
||||
*/
|
||||
class AchievementFactory extends Factory
|
||||
{
|
||||
protected $model = Achievement::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'key' => fake()->randomElement(['first_workout', 'streak_3', 'streak_7', 'streak_30', 'streak_100']),
|
||||
'earned_at' => fake()->dateTimeBetween('-90 days', 'now'),
|
||||
'meta' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Database\Factories;
|
||||
|
||||
use Functional\Streaks\Enums\GoalPeriod;
|
||||
use Functional\Streaks\Enums\GoalType;
|
||||
use Functional\Streaks\Models\Goal;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Goal>
|
||||
*/
|
||||
class GoalFactory extends Factory
|
||||
{
|
||||
protected $model = Goal::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$type = fake()->randomElement(GoalType::cases());
|
||||
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'type' => $type,
|
||||
'target' => match ($type) {
|
||||
GoalType::WeeklySessions => fake()->numberBetween(2, 6),
|
||||
GoalType::WeeklyMinutes => fake()->numberBetween(60, 300),
|
||||
GoalType::WeeklyVolume => fake()->numberBetween(1000, 10000),
|
||||
},
|
||||
'period' => GoalPeriod::Week,
|
||||
'is_active' => fake()->boolean(85),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Database\Factories;
|
||||
|
||||
use Functional\Streaks\Enums\StreakDaySource;
|
||||
use Functional\Streaks\Models\StreakDay;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<StreakDay>
|
||||
*/
|
||||
class StreakDayFactory extends Factory
|
||||
{
|
||||
protected $model = StreakDay::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'date' => fake()->unique()->dateTimeBetween('-60 days', 'now')->format('Y-m-d'),
|
||||
'source' => fake()->randomElement(StreakDaySource::cases()),
|
||||
'workout_session_id' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Database\Factories;
|
||||
|
||||
use Functional\Streaks\Models\Streak;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Streak>
|
||||
*/
|
||||
class StreakFactory extends Factory
|
||||
{
|
||||
protected $model = Streak::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$current = fake()->numberBetween(0, 60);
|
||||
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'current_count' => $current,
|
||||
'longest_count' => max($current, fake()->numberBetween(0, 120)),
|
||||
'last_active_date' => $current > 0
|
||||
? fake()->dateTimeBetween('-2 days', 'now')->format('Y-m-d')
|
||||
: null,
|
||||
'freezes_available' => fake()->numberBetween(0, 3),
|
||||
'freeze_last_granted_on' => fake()->optional(0.4)->dateTimeBetween('-30 days', 'now')?->format('Y-m-d'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user