Initial commit
This commit is contained in:
38
app/Models/Attempt.php
Normal file
38
app/Models/Attempt.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
#[Fillable(['candidate_id', 'quiz_id', 'score', 'max_score', 'started_at', 'finished_at'])]
|
||||
class Attempt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $casts = [
|
||||
'started_at' => 'datetime',
|
||||
'finished_at' => 'datetime',
|
||||
'score' => 'float',
|
||||
'max_score' => 'integer',
|
||||
];
|
||||
|
||||
public function candidate(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Candidate::class);
|
||||
}
|
||||
|
||||
public function quiz(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Quiz::class);
|
||||
}
|
||||
|
||||
public function answers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Answer::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user