47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Store;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
use App\Models\Tag;
|
|
use App\Models\Admin\Administrator;
|
|
|
|
class StockBatch extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
|
|
protected $table = 'store_stock_batches';
|
|
|
|
protected $fillable = ['admin_user_id', 'store_id', 'remarks', 'sn', 'tag_id', 'status'];
|
|
|
|
protected $attributes = [
|
|
'status' => 0
|
|
];
|
|
|
|
public function store()
|
|
{
|
|
return $this->belongsTo(Store::class, 'store_id');
|
|
}
|
|
|
|
public function adminUser()
|
|
{
|
|
return $this->belongsTo(Administrator::class, 'admin_user_id');
|
|
}
|
|
|
|
public function tag()
|
|
{
|
|
return $this->belongsTo(Tag::class, 'tag_id');
|
|
}
|
|
|
|
public function productSkus()
|
|
{
|
|
return $this->belongsToMany(\App\Models\ProductSku::class, 'store_stock_batch_goods', 'batch_id', 'product_sku_id')->withPivot('amount');
|
|
}
|
|
|
|
public function logs()
|
|
{
|
|
return $this->morphMany(StockLog::class, 'source');
|
|
}
|
|
}
|