<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class MaterialBox extends Model
{
    use ModelLogChanging;

    protected $fillable=['code','status'];

    static public $enums=[
        'status'=>[
            '在库外'=>1,
            '在U型线'=>2,
            '在缓存架'=>3,
            '在立库'=>4,
            '在出库中'=>5,
            '在入库中'=>6,
            '未知'=>7,
            '异常'=>8,
        ],
    ];
    function __construct(array $attributes = [])
    {
        foreach (self::$enums as &$enum) {
            $enum=$enum+array_flip($enum);
        }
        parent::__construct($attributes);
    }

    public function getStatusAttribute($value)
    {
        return self::$enums['status'][$value];
    }
    public function setStatusAttribute($value)
    {
        $this->attributes['status']=self::$enums['status'][$value];
    }
}
