step 1, 2 and 3 of the implementation plan
This commit is contained in:
50
app/Models/QuestionGroup.php
Normal file
50
app/Models/QuestionGroup.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
final class QuestionGroup extends Model
|
||||
{
|
||||
/**
|
||||
* Fillable attributes for mass assignment.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'name',
|
||||
'sort_order',
|
||||
'description',
|
||||
'scoring_instructions',
|
||||
];
|
||||
|
||||
/**
|
||||
* Cast attributes to specific types.
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'category_id' => 'integer',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category that owns this question group.
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all questions for this question group.
|
||||
*/
|
||||
public function questions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Question::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user