<?php

namespace App\Models;

use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;

class Branch extends Model
{
    use BelongsToTenant, HasFactory, SoftDeletes;

    protected $fillable = [
        'uuid',
        'tenant_id',
        'name',
        'code',
        'emirate',
        'address',
        'phone',
        'email',
        'is_main',
        'status',
    ];

    protected static function boot()
    {
        parent::boot();
        static::creating(function ($model) {
            if (! $model->uuid) {
                $model->uuid = (string) Str::uuid();
            }
        });
    }

    public function departments()
    {
        return $this->hasMany(Department::class);
    }

    public function counters()
    {
        return $this->hasMany(Counter::class);
    }

    public function employees()
    {
        return $this->hasMany(Employee::class);
    }
}
