<?php

namespace Mehrab\Region\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Mehrab\City\Models\City;
use Mehrab\Service\Models\Service;

class Region extends Model
{
    use HasFactory;

    const ACTIVE = 'active';
    const INACTIVE = 'inactive';
    public static $status = [self::ACTIVE,self::INACTIVE];

    //وضعیت مدل هایی که پلی مورفیک با region دارند : فعال هستند یا غیر فعال
    const ACTIVE_PROVIDE = 'active';
    const INACTIVE_PROVIDE = 'inactive';
    public static $status_PROVIDE = [self::ACTIVE,self::INACTIVE];

    protected $fillable = [
        'name',
        'slug',
        'priority'
    ];

    public function city(){
        return $this->belongsTo(City::class,'city_id');
    }

    public function services()
    {
        return $this->morphedByMany(Service::class, 'regionable','regionable')
            ->withPivot('status_provide')
            ->withTimestamps();
    }

    public function managers()
    {
//        return $this->morphedByMany('App\manager', 'regionable')->withPivot('status')->withTimestamps();
    }
}
