relationLoaded('user') ? $this->getRelation('user') : User::find($this->user_id); return \App\Services\Survey\SurveyIdentity::respondent($user, $this->data, $this->snapshot); } protected $casts = ['data' => 'json', 'snapshot' => 'array']; public function user() { return $this->hasOne(User::class, 'id', 'user_id'); } }