mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
52 lines
909 B
PHP
52 lines
909 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\traits\Filter;
|
|
|
|
class Goods extends Model
|
|
{
|
|
use Filter;
|
|
|
|
//查询字段
|
|
public $fieldSearchable = [
|
|
'type_id',
|
|
'brand_id',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'title',
|
|
'img_url',
|
|
'type_id',
|
|
'brand_id',
|
|
'goods_code',
|
|
];
|
|
|
|
public function getImgUrlAttribute($value)
|
|
{
|
|
if (0 === strpos($value, 'ju8hn6/erp/shop')) {
|
|
$value = config('filesystems.disks.aliyun.url') . $value;
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
|
|
/**
|
|
* 多规格
|
|
*/
|
|
public function skus()
|
|
{
|
|
return $this->hasMany(GoodsSku::class, 'goods_id');
|
|
}
|
|
|
|
public function brand()
|
|
{
|
|
return $this->belongsTo(GoodsBrand::class, 'brand_id', 'id');
|
|
}
|
|
|
|
public function type()
|
|
{
|
|
return $this->belongsTo(GoodsType::class, 'type_id', 'id');
|
|
}
|
|
}
|