<?php

namespace Modules\Mall\Models;

use App\Models\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\Mall\Models\Traits\BelongsToOrder;
use Modules\Mall\Models\Traits\HasRegion;

class OrderExpress extends Model
{

    use BelongsToOrder,
        HasRegion;

    protected $table = 'mall_order_expresses';

    protected $dates = [
        'deliver_at',
        'receive_at',
    ];

    const TYPE_EXPRESS   = 1;
    const TYPE_LOGISTICS = 2;

    const TYPE_MAP = [
        self::TYPE_EXPRESS   => '快递',
        self::TYPE_LOGISTICS => '物流',
    ];

    /**
     * Notes   : 订单物流信息
     *
     * @Date   : 2021/5/25 12:04 下午
     * @Author : < Jason.C >
     * @return BelongsTo
     */
    public function express(): BelongsTo
    {
        return $this->belongsTo(Express::class);
    }

    public function getTypeTextAttribute(): string
    {
        return self::TYPE_MAP[$this->type];
    }

}
