<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Stream extends Model
{
    protected $fillable = ['class_id', 'name', 'class_teacher_id', 'capacity'];

    public function schoolClass() { return $this->belongsTo(SchoolClass::class, 'class_id'); }
    public function classTeacher() { return $this->belongsTo(Teacher::class, 'class_teacher_id'); }
    public function students() { return $this->hasMany(Student::class); }
    public function timetables() { return $this->hasMany(Timetable::class); }
    public function attendances() { return $this->hasMany(Attendance::class); }

    public function getFullNameAttribute(): string
    {
        return $this->schoolClass->name . ' ' . $this->name;
    }
}
