mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
58 lines
1005 B
PHP
58 lines
1005 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\traits\Filter;
|
|
|
|
class GoodsSku extends Model
|
|
{
|
|
use Filter;
|
|
|
|
//查询字段
|
|
public $fieldSearchable = [
|
|
'sku_title',
|
|
'status',
|
|
];
|
|
|
|
/**
|
|
* 不可批量赋值的属性。为空则所有熟悉都可以批量赋值
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $guarded = [];
|
|
|
|
protected $hidden = ['created_at'];
|
|
|
|
/**
|
|
* 获取状态
|
|
*
|
|
* @param string $value
|
|
* @return string
|
|
*/
|
|
public function getStatusAttribute($value)
|
|
{
|
|
$map = [
|
|
0 => '下架',
|
|
1 => '在售',
|
|
2 => '预警',
|
|
];
|
|
return $map[$value];
|
|
}
|
|
|
|
/**
|
|
* 此规格从属于一个商品
|
|
*/
|
|
public function goods()
|
|
{
|
|
return $this->hasOne(Goods::class, 'id', 'goods_id');
|
|
}
|
|
|
|
/**
|
|
* 此规格每日记录
|
|
*/
|
|
public function daily()
|
|
{
|
|
return $this->hasOne(DailyStockRecord::class, 'sku_id', 'id');
|
|
}
|
|
}
|