<?php

namespace App\Models;

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

class StudentGrade extends Model
{
    use HasFactory;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'student_grades';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'rank',
        'quarter_average',
        'main_exam',
        'monitoring_exam_2',
        'monitoring_exam_1',
        'written_tests',
        'practical_work',
        'oral_exam',
        'sum',
        'coefficient',
        'prof_id',
        'matiere_id',
        'score_id',
        'classe_id',
        'eleve_id',
    ];

    /**
     * Get the professor associated with the student grade.
     */
    public function professor()
    {
        return $this->belongsTo(Prof::class, 'prof_id');
    }

    /**
     * Get the subject associated with the student grade.
     */
    public function matiere()
    {
        return $this->belongsTo(Matiere::class, 'matiere_id');
    }

    /**
     * Get the tripler associated with the student grade.
     */
    public function score()
    {
        return $this->belongsTo(Score::class, 'score_id');
    }

        /**
     * Get the classe associated with the student grade.
     */
    public function classe()
    {
        return $this->belongsTo(Classe::class, 'classe_id');
    }

        /**
     * Get the eleve associated with the student grade.
     */
    public function eleve()
    {
        return $this->belongsTo(Eleve::class, 'eleve_id');
    }
}
