<?php

namespace App\Modules\Pilkades\Models;

use App\Core\Concerns\HasUuid;
use App\Modules\Pilkades\Models\Concerns\BelongsToDesa;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class Candidate extends Model
{
    use BelongsToDesa, HasFactory, HasUuid, SoftDeletes;

    protected $table = 'candidates';

    protected $fillable = [
        'desa_id',
        'nomor_urut',
        'nama_lengkap',
        'foto',
        'status',
    ];

    public function profile(): HasOne
    {
        return $this->hasOne(CandidateProfile::class);
    }

    public function programs(): HasMany
    {
        return $this->hasMany(CandidateProgram::class)->orderBy('urutan');
    }

    public function gallery(): HasMany
    {
        return $this->hasMany(CandidateGallery::class)->orderBy('urutan');
    }

    public function videos(): HasMany
    {
        return $this->hasMany(CandidateVideo::class)->orderBy('urutan');
    }
}
