Build & Deploy / build (push) Successful in 18s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Functional\Programs\Models;
|
|
|
|
use Functional\Programs\Database\Factories\ProgramFactory;
|
|
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;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* Un programme = planning de routines sur plusieurs semaines, possédé par un utilisateur.
|
|
*
|
|
* @property string $name
|
|
* @property string $slug
|
|
* @property string|null $description
|
|
* @property int $duration_weeks
|
|
* @property int|null $days_per_week
|
|
* @property bool $is_public
|
|
*/
|
|
#[UseFactory(ProgramFactory::class)]
|
|
class Program extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'user_id', 'name', 'slug', 'description', 'duration_weeks', 'days_per_week', 'is_public',
|
|
];
|
|
|
|
protected $casts = [
|
|
'duration_weeks' => 'integer',
|
|
'days_per_week' => 'integer',
|
|
'is_public' => 'boolean',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function programSlots(): HasMany
|
|
{
|
|
return $this->hasMany(ProgramSlot::class);
|
|
}
|
|
}
|