59 lines
1.0 KiB
PHP
59 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Ujian extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'mapel_id',
|
|
'judul',
|
|
'keterangan',
|
|
'tanggal_post',
|
|
'waktu',
|
|
'soal',
|
|
'terbit',
|
|
'bobot_pg',
|
|
'bobot_essay',
|
|
];
|
|
|
|
protected $casts = [
|
|
'tanggal_post' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
|
|
public function soalPilgan()
|
|
{
|
|
return $this->hasMany(SoalPilgan::class);
|
|
}
|
|
|
|
public function soalEssay()
|
|
{
|
|
return $this->hasMany(SoalEssay::class);
|
|
}
|
|
public function mapel()
|
|
{
|
|
return $this->belongsTo(Mapel::class, 'mapel_id');
|
|
}
|
|
|
|
public function hasilUjian()
|
|
{
|
|
return $this->hasMany(HasilUjian::class);
|
|
}
|
|
|
|
public function kelas()
|
|
{
|
|
return $this->belongsToMany(Kelas::class, 'kelas_ujian')
|
|
->withPivot('deadline')
|
|
->withTimestamps();
|
|
}
|
|
|
|
|
|
}
|