<?php

namespace App;

use App\Traits\ModelTimeFormat;
use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class OrderFreeze extends Model
{
    use ModelLogChanging;
    use ModelTimeFormat;

    protected $fillable = [
        "status","logistic_id","province_id","city_id","district_id","town_id","street_id","thawed_at"
    ];

    const status=[
        0 => "冻结",
        1 => "解冻",
    ];

    public function logistic()
    {  //承运商
        return $this->belongsTo(Logistic::class);
    }
    public function province()
    {   //省
        return $this->belongsTo(Region::class)->where("type",1);
    }
    public function city()
    {   //市
        return $this->belongsTo(Region::class)->where("type",2);
    }
    public function district()
    {   //区县
        return $this->belongsTo(Region::class)->where("type",3);
    }
    public function town()
    {   //乡镇
        return $this->belongsTo(Region::class)->where("type",4);
    }
    public function street()
    {   //村街
        return $this->belongsTo(Region::class)->where("type",5);
    }
}
