<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Spatie\Activitylog\Models\Concerns\LogsActivity;
use Spatie\Activitylog\Support\LogOptions;

class Siswa extends Model
{
    use HasFactory, LogsActivity;

    protected $table = 'siswa';

    protected $fillable = [
        'nisn',
        'nama',
        'kelas',
        'jurusan',
        'status_kelulusan',
        'tahun_ajaran',
    ];

    public function dokumen(): HasMany
    {
        return $this->hasMany(DokumenSiswa::class, 'siswa_id');
    }

    public function pilihanSekolah(): HasOne
    {
        return $this->hasOne(PilihanSekolah::class, 'siswa_id');
    }

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->logOnly(['nisn', 'nama', 'kelas', 'jurusan', 'status_kelulusan', 'tahun_ajaran'])
            ->logOnlyDirty();
    }
}
