<?php

namespace App\Models;

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

class Pelanggaran extends Model
{
    use HasFactory;
    protected $table = 'pelanggarans';
    protected $primaryKey = 'id_pelanggaran';

    protected $fillable = [

        'id_siswa',
        'id_guru',
        'id_point_pelanggaran',
        'tanggal',
        'saldo_pelanggaran',
        'keterangan',
    ];

    public function siswa(): BelongsTo
    {
        return $this->belongsTo(Siswa::class, 'id_siswa', 'id_siswa');
    }

    public function guru(): BelongsTo
    {
        return $this->belongsTo(Guru::class, 'id_guru', 'id_guru');
    }

    public function point(): BelongsTo
    {
        return $this->belongsTo(PointPelanggaran::class, 'id_point_pelanggaran', 'id_point_pelanggaran');
    }
}
