<?php

namespace App\Models;

use App\Models\Traits\BelongsToDealer;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Branch extends Model
{
    use HasFactory;
    use BelongsToDealer;

    protected $fillable = [
        'name',
        'address',
        'is_default',
        'is_active',
    ];

    protected $casts = [
        'is_default' => 'bool',
        'is_active' => 'bool',
    ];

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

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

