<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Siswa extends Authenticatable
{
    use HasFactory;

    protected $table = 'siswas';
    protected $primaryKey = 'id_siswa';
    public $incrementing = true;
    protected $keyType = 'int';

    protected $fillable = [
        'nisn',
        'nama',
        'tempat_lahir',
        'tanggal_lahir',
        'id_kelas',
        'password',
        'foto_profil'
    ];

    protected $hidden = [
        'password',
        'remember_token',
    ];

    public function kelas()
    {
        return $this->belongsTo(Kelas::class, 'id_kelas', 'id_kelas');
    }

    public function pengumpulanTugas()
    {
        return $this->hasMany(PengumpulanTugas::class, 'id_siswa', 'id_siswa');
    }

    public function badges()
    {
        return $this->hasMany(SiswaBadge::class, 'id_siswa', 'id_siswa');
    }

    public function leaderboards()
    {
        return $this->hasMany(Leaderboard::class, 'id_siswa', 'id_siswa');
    }

    public function pesertaChallenges()
    {
        return $this->hasMany(PesertaChallenge::class, 'id_siswa', 'id_siswa');
    }
}