HoshiAI-be/app/Models/Question.php
2025-11-11 19:41:58 +01:00

57 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Question extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'title',
'description',
'type',
'difficulty',
'category_id',
'author_id',
'variants',
'is_pending_question',
'correct_answers',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'is_pending_question' => 'boolean',
'correct_answers' => 'array',
'variants' => 'array',
];
/**
* Category relation (nullable, on delete set null).
*/
public function category()
{
return $this->belongsTo(Category::class);
}
/**
* Author relation (nullable, on delete set null).
*/
public function author()
{
return $this->belongsTo(User::class, 'author_id');
}
}