ajoute le portail Laravel : connexion prof/élève, session unique, gestion de classe, salle d'attente
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
aa31b6112f
commit
30e14b1c54
191 changed files with 25324 additions and 0 deletions
61
portail/app/Models/Classe.php
Normal file
61
portail/app/Models/Classe.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Classe extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['etablissement_id', 'user_id', 'nom', 'formation', 'code_classe'];
|
||||
|
||||
protected $casts = [
|
||||
'archivee_a' => '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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue