Added quiz features

This commit is contained in:
m.razaghi
2026-08-06 14:20:38 +03:30
parent af21c1c77e
commit 041a3e7bd5
12 changed files with 665 additions and 1 deletions

47
app/Models/Quiz.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Quiz extends Model
{
use HasFactory;
protected $fillable = [
'category_id',
'title',
'slug',
'year',
'type',
'duration_minutes',
'has_negative_score',
'is_free',
'is_published',
'description',
];
protected $casts = [
'year' => 'integer',
'duration_minutes' => 'integer',
'has_negative_score' => 'boolean',
'is_free' => 'boolean',
'is_published' => 'boolean',
];
public function category()
{
return $this->belongsTo(QuizCategory::class, 'category_id');
}
public function questions()
{
return $this->hasMany(Question::class, 'quiz_id')->orderBy('order');
}
public function attempts()
{
return $this->hasMany(UserQuizAttempt::class, 'quiz_id');
}
}