Added quiz features
This commit is contained in:
47
app/Models/Quiz.php
Normal file
47
app/Models/Quiz.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user