<?php

namespace App;

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

class Store extends Model
{
    use ModelTimeFormat;
    use SoftDeletes;

    protected $fillable=[
        'asn_code','warehouse_id','owner_id','stored_method','status','remark','deleted_at','is_fast_stored'
    ];

//    protected $appends=[
//        'owner_name','warehouse_name'
//    ];

    public function owner(){
        return $this->belongsTo('App\Owner','owner_id','id');
    }

    public function warehouse(){
        return $this->belongsTo('App\Warehouse','warehouse_id','id');
    }
    public function storeItems(){
        return $this->hasMany('App\StoreItems','store_id','id');
}

//    public function getOwnerNameAttribute()
//    {
//        return $this['owner']? $this['owner']['name']:null;
//    }
//
//    public function getWarehouseNameAttribute()
//    {
//        return $this['warehouse']?$this['warehouse']['name']:null;
//    }
}
