<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Teacher extends Model
{
  use HasFactory;

  protected $fillable = [
    'name',
    'id',
    'firstName',
    'lastName',
    'dateOfBirth',
    'gender',
    'email',
    'contact',
    'skills',
  ];

  public function schedules()
  {
    return $this->belongsToMany(
      'App\Models\Schedule',
      'schedule_teacher_rel',
      'teacher_id',
      'schedule_id'
    );
  }

  public function exams()
  {
    return $this->belongsToMany(
      'App\Models\Exam',
      'exam_teacher_rel',
      'teacher_id',
      'exam_id'
    );
  }

  public function exam_results()
  {
    return $this->belongsToMany(
      'App\Models\ExamResult',
      'exam_result_teacher_rel',
      'teacher_id',
      'exam_result_id'
    );
  }

  public function attendances()
  {
    return $this->belongsToMany(
      'App\Models\Attendance',
      'attendance_teacher_rel',
      'teacher_id',
      'attendance_id'
    );
  }

  public function notices()
  {
    return $this->belongsToMany(
      'App\Models\Notice',
      'notice_teacher_rel',
      'teacher_id',
      'notice_id'
    );
  }
}
