70d4767890
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
702 B
PHP
37 lines
702 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ResultatDiag extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'resultat_diags';
|
|
|
|
protected $fillable = [
|
|
'id_user',
|
|
'date_passage',
|
|
'score_total',
|
|
'niveau_stress',
|
|
'event_ids',
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'id_user');
|
|
}
|
|
|
|
public function getEventsAttribute()
|
|
{
|
|
if (! $this->event_ids) {
|
|
return collect();
|
|
}
|
|
$ids = explode(';', $this->event_ids);
|
|
|
|
return StressEvent::whereIn('id', $ids)->get();
|
|
}
|
|
}
|