<?php

namespace App\Models;

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

class Department extends Model
{
    use HasFactory;
    use SoftDeletes;
    use BelongsToDealer;

    protected $fillable = [
        'dealer_id',
        'name',
        'code',
        'slug',
        'is_system',
        'is_builtin',
    ];

    protected $casts = [
        'is_system' => 'bool',
        'is_builtin' => 'bool',
    ];

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

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