first
This commit is contained in:
@@ -7,16 +7,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class QuestionnaireQuestion extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'questionnaire_set_id', 'question_text', 'question_type',
|
||||
'options_json', 'is_required', 'sort_order',
|
||||
'questionnaire_set_id', 'parent_id', 'question_text', 'question_type',
|
||||
'options_json', 'rating_labels', 'is_required', 'sort_order',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'options_json' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
'options_json' => 'array',
|
||||
'rating_labels' => 'array',
|
||||
'is_required' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -25,6 +26,16 @@ class QuestionnaireQuestion extends Model
|
||||
return $this->belongsTo(QuestionnaireSet::class);
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(QuestionnaireQuestion::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(QuestionnaireQuestion::class, 'parent_id')->orderBy('sort_order');
|
||||
}
|
||||
|
||||
public function answers()
|
||||
{
|
||||
return $this->hasMany(QuestionnaireAnswer::class);
|
||||
|
||||
Reference in New Issue
Block a user