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