6
0
Fork 0
jiqu-library-server/app/Models/Store/StockLog.php

56 lines
1.3 KiB
PHP

<?php
namespace App\Models\Store;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use App\Models\Tag;
class StockLog extends Model
{
use HasFactory, HasDateTimeFormatter;
const TAG_OUT = 1;// 出库, 调出
const TAG_IN = 2;// 入库, 进货
const TAG_CARRY = 3;// 提货, 线下订单
const TAG_LOSS = 4;// 报损
const TAG_SELF = 5;// 自用
const TAG_SEND = 9;// 发货, 线上订单发货(绑定门店)
const TAG_JOIN = 13;// 调入
protected $table = 'store_stock_logs';
protected $fillable = ['operator_type', 'operator_id', 'operator_name', 'amount', 'product_sku_id', 'remarks', 'balance', 'source_id', 'source_type', 'store_id', 'tag_id'];
public static function tags()
{
return Tag::where('type', Tag::TYPE_STORE_STOCK);
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function productSku()
{
return $this->belongsTo(\App\Models\ProductSku::class, 'product_sku_id');
}
public function operator()
{
return $this->morphTo();
}
public function source()
{
return $this->morphTo();
}
public function tag()
{
return $this->belongsTo(Tag::class, 'tag_id');
}
}