'datetime', ]; protected static function booted(): void { static::creating(function (Classe $classe) { $classe->code_classe ??= static::genererCodeUnique(); }); } public static function genererCodeUnique(): string { do { $code = Str::upper(Str::random(6)); } while (static::where('code_classe', $code)->exists()); return $code; } public function etablissement(): BelongsTo { return $this->belongsTo(Etablissement::class); } public function prof(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } public function eleves(): HasMany { return $this->hasMany(Eleve::class); } public function seances(): HasMany { return $this->hasMany(Seance::class); } public function estArchivee(): bool { return $this->archivee_a !== null; } }