<?php

namespace App\Models;

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

class Attendance extends Model
{
  use HasFactory;

  protected $table = 'attendance';

  protected $fillable = [
    'check_time',
    'student_email',
    'subject_id',
    'remarks',
  ];

  public function teachers()
  {
    return $this->belongsToMany(
      'App\Models\Attendance',
      'attendance_teacher_rel',
      'attendance_id', // foreign key name of the model on which you are defining the relationship
      'teacher_id'
    ); // foreign key name of the model that you are joining to
  }

  public function student()
  {
    return $this->belongsTo('App\Models\Student');
  }

  public function subject()
  {
    return $this->belongsTo('App\Models\Subject');
  }
}
