<?php

namespace App\Models;

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

class Quartier extends Model
{
    use HasFactory;

    protected $fillable = [
        'ville_id', 'nom', 'code', 'actif',
    ];

    protected $casts = [
        'actif' => 'boolean',
    ];

    // Relations
    public function ville(): \Illuminate\Database\Eloquent\Relations\BelongsTo
    {
        return $this->belongsTo(Ville::class);
    }

    public function clients(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Client::class);
    }

    public function candidats(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Candidat::class, 'quartier_domicile_id');
    }

    public function parrains(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Parrain::class);
    }

    public function besoins(): \Illuminate\Database\Eloquent\Relations\HasMany
    {
        return $this->hasMany(Besoin::class);
    }
}
