53 lines
1.0 KiB
PHP
Executable File
53 lines
1.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Question extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'test_id',
|
|
'type',
|
|
'question_text',
|
|
'explanation',
|
|
'score',
|
|
'sort_order',
|
|
'is_required',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_required' => 'boolean',
|
|
];
|
|
|
|
public function test(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Test::class);
|
|
}
|
|
|
|
public function answers(): HasMany
|
|
{
|
|
return $this->hasMany(Answer::class);
|
|
}
|
|
|
|
public function matchingPairs(): HasMany
|
|
{
|
|
return $this->hasMany(QuestionMatchingPair::class);
|
|
}
|
|
|
|
public function orderingItems(): HasMany
|
|
{
|
|
return $this->hasMany(QuestionOrderingItem::class);
|
|
}
|
|
|
|
public function responses(): HasMany
|
|
{
|
|
return $this->hasMany(TestResponse::class);
|
|
}
|
|
}
|