belongsTo(User::class, 'teacher_id'); } /** * Get the subject associated with this assignment */ public function subject(): BelongsTo { return $this->belongsTo(Subject::class, 'subject_id'); } /** * Get the class associated with this assignment */ public function class(): BelongsTo { return $this->belongsTo(ClassRoom::class, 'class_id'); } /** * Scope for current academic year */ public function scopeCurrentYear($query) { return $query->where('academic_year', now()->format('Y')); } /** * Scope for specific academic year */ public function scopeForYear($query, $year) { return $query->where('academic_year', $year); } public function attendances() { return $this->hasMany(Attendances::class); } }