Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Models;
|
||||
|
||||
use Functional\Streaks\Database\Factories\AchievementFactory;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Badge débloqué par un user à un palier donné (ex: streak_7, streak_30, first_workout).
|
||||
* Unique par (user, key) : un badge n'est débloqué qu'une seule fois.
|
||||
*
|
||||
* @property int $user_id
|
||||
* @property string $key
|
||||
* @property \Illuminate\Support\Carbon $earned_at
|
||||
* @property array|null $meta
|
||||
*/
|
||||
#[UseFactory(AchievementFactory::class)]
|
||||
class Achievement extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'key', 'earned_at', 'meta',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'earned_at' => 'datetime',
|
||||
'meta' => 'array',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Models;
|
||||
|
||||
use Functional\Streaks\Database\Factories\GoalFactory;
|
||||
use Functional\Streaks\Enums\GoalPeriod;
|
||||
use Functional\Streaks\Enums\GoalType;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Objectif hebdomadaire fixé par le user (nombre de séances, minutes ou volume).
|
||||
*
|
||||
* @property int $user_id
|
||||
* @property GoalType $type
|
||||
* @property int $target
|
||||
* @property GoalPeriod $period
|
||||
* @property bool $is_active
|
||||
*/
|
||||
#[UseFactory(GoalFactory::class)]
|
||||
class Goal extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'type', 'target', 'period', 'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => GoalType::class,
|
||||
'target' => 'integer',
|
||||
'period' => GoalPeriod::class,
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Models;
|
||||
|
||||
use Functional\Streaks\Database\Factories\StreakFactory;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Streak courant d'un utilisateur (une ligne par user) : régularité d'entraînement, gamification.
|
||||
*
|
||||
* @property int $user_id
|
||||
* @property int $current_count
|
||||
* @property int $longest_count
|
||||
* @property \Illuminate\Support\Carbon|null $last_active_date
|
||||
* @property int $freezes_available
|
||||
* @property \Illuminate\Support\Carbon|null $freeze_last_granted_on
|
||||
*/
|
||||
#[UseFactory(StreakFactory::class)]
|
||||
class Streak extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'current_count', 'longest_count', 'last_active_date',
|
||||
'freezes_available', 'freeze_last_granted_on',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'current_count' => 'integer',
|
||||
'longest_count' => 'integer',
|
||||
'last_active_date' => 'date',
|
||||
'freezes_available' => 'integer',
|
||||
'freeze_last_granted_on' => 'date',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Functional\Streaks\Models;
|
||||
|
||||
use Functional\Streaks\Database\Factories\StreakDayFactory;
|
||||
use Functional\Streaks\Enums\StreakDaySource;
|
||||
use Functional\Users\Models\User;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Un jour d'activité compté pour le streak (séance réelle, saisie manuelle, freeze ou repos planifié).
|
||||
* Unique par (user, date) : au plus un jour par user et par date.
|
||||
*
|
||||
* @property int $user_id
|
||||
* @property \Illuminate\Support\Carbon $date
|
||||
* @property StreakDaySource $source
|
||||
* @property int|null $workout_session_id
|
||||
*/
|
||||
#[UseFactory(StreakDayFactory::class)]
|
||||
class StreakDay extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id', 'date', 'source', 'workout_session_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
'source' => StreakDaySource::class,
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user