4f54340e89
Backend: - table audits réellement alimentée via trait Auditable (observers Eloquent) sur Utilisateur, SaisieTracker, Feed, Emotion ; mot de passe jamais loggé - 4 nouveaux tests (19/19 au total) Frontend web: - en-tête/pied République Française ajoutés aux pages connexion/inscription - bouton variant danger réellement rouge (tokens erreur DSFR) Mobile: - ~30 libellés ré-accentués (Intensité, Succès, Déconnexion, Répartition...) - Colors.secondary = rouge Marianne #E1000F (différenciation cartes/icônes) - vrai camembert SVG des rapports (react-native-svg) Docs: plans oraux mis à jour (audits actif, 29 tests, stockage JWT en Q/R) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\Auditable;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Emotion extends Model
|
|
{
|
|
use Auditable, HasFactory;
|
|
|
|
protected $table = 'emotions';
|
|
|
|
protected $fillable = [
|
|
'nom',
|
|
'couleur',
|
|
'icone',
|
|
'niveau',
|
|
'parent_id',
|
|
'est_actif',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'niveau' => 'integer',
|
|
'est_actif' => 'boolean',
|
|
];
|
|
}
|
|
|
|
// ──── Relations ────
|
|
|
|
public function parent(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Emotion::class, 'parent_id');
|
|
}
|
|
|
|
public function enfants(): HasMany
|
|
{
|
|
return $this->hasMany(Emotion::class, 'parent_id');
|
|
}
|
|
|
|
public function saisieTrackers(): HasMany
|
|
{
|
|
return $this->hasMany(SaisieTracker::class);
|
|
}
|
|
|
|
// ──── Scopes ────
|
|
|
|
public function scopeActives(Builder $query): Builder
|
|
{
|
|
return $query->where('est_actif', true);
|
|
}
|
|
|
|
public function scopeNiveau(Builder $query, int $niveau): Builder
|
|
{
|
|
return $query->where('niveau', $niveau);
|
|
}
|
|
}
|