<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class Candidate extends Model
{
    protected $fillable = [
        'slug',
        'user_id',
        'seat_id',

        'party_name',
        'symbol_name',
        'photo',
        'symbol_photo',

        'nid_number_en',
        'nid_number_bn',

        'education',
        'bio',
        'election_manifesto',

        'status',
    ];

    protected $casts = [
        // kept for forward compatibility
        'previous_experience' => 'array',
        'total_votes' => 'integer',
        'date_of_birth' => 'date',
        'ward_no' => 'integer',
    ];


    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function seat(): BelongsTo
    {
        return $this->belongsTo(Seat::class);
    }

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

    public function tasks(): HasMany
    {
        return $this->hasMany(Task::class);
    }


    public function getRouteKeyName(): string
    {
        return 'slug';
    }
}
