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>
84 lines
1.8 KiB
PHP
84 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\Auditable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Tymon\JWTAuth\Contracts\JWTSubject;
|
|
|
|
class Utilisateur extends Authenticatable implements JWTSubject
|
|
{
|
|
use Auditable, HasFactory, Notifiable, SoftDeletes;
|
|
|
|
protected $table = 'utilisateurs';
|
|
|
|
protected $fillable = [
|
|
'nom',
|
|
'prenom',
|
|
'email',
|
|
'password',
|
|
'role_id',
|
|
'est_actif',
|
|
'consentement_rgpd',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
'est_actif' => 'boolean',
|
|
'consentement_rgpd' => 'boolean',
|
|
];
|
|
}
|
|
|
|
// ──── JWTSubject ────
|
|
|
|
public function getJWTIdentifier(): mixed
|
|
{
|
|
return $this->getKey();
|
|
}
|
|
|
|
public function getJWTCustomClaims(): array
|
|
{
|
|
return [
|
|
'role' => $this->role->nom,
|
|
];
|
|
}
|
|
|
|
// ──── Relations ────
|
|
|
|
public function role(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Role::class);
|
|
}
|
|
|
|
public function tracker(): HasOne
|
|
{
|
|
return $this->hasOne(Tracker::class);
|
|
}
|
|
|
|
public function contactsUrgence(): HasMany
|
|
{
|
|
return $this->hasMany(ContactUrgence::class);
|
|
}
|
|
|
|
// ──── Helpers ────
|
|
|
|
public function estAdmin(): bool
|
|
{
|
|
return $this->role->nom === 'administrateur';
|
|
}
|
|
}
|