*/ protected $casts = []; protected $appends = ['survey_name']; /** * The survey section belongs to. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function survey() { return $this->belongsTo(Survey::class); } /** * The questions of the section. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function questions() { return $this->hasMany(SurveyQuestion::class, 'section_id'); } public function getSurveyNameAttribute() { return Survey::withTrashed()->find($this->survey_id)->name; } }