Files
004_comission/nssheung/School-Management-System/src/php74-httpd/example-app/app/Models/Exam.php
louiscklaw 653422de08 update,
2025-01-31 21:09:49 +08:00

51 lines
880 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Exam extends Model
{
use HasFactory;
protected $table = 'exams';
protected $fillable = ['date', 'subject_id', 'title', 'remarks'];
public function teachers()
{
return $this->belongsToMany(
'App\Models\Teacher',
'exam_teacher_rel',
'exam_id',
'teacher_id'
);
}
public function students()
{
return $this->belongsToMany(
'App\Models\Student',
'exam_student_rel',
'exam_id',
'student_id'
);
}
public function exam_results()
{
return $this->belongsToMany(
'App\Models\ExamResult',
'exam_exam_result_rel',
'exam_id',
'exam_result_id'
);
}
public function subject()
{
return $this->belongsTo('App\Models\Subject');
}
}