<?php

namespace App\Models;

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

class Notice extends Model
{
  use HasFactory;
  protected $table = 'notices';
  protected $fillable = ['date', 'subject', 'content', 'from', 'to'];

  public function students()
  {
    return $this->belongsToMany(
      'App\Models\Student',
      'notice_student_rel',
      'notice_id',
      'student_id'
    );
  }

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