<?php

namespace App\Models;

use App\Models\traits\Filter;

class GroupGoods extends Model
{
    use Filter;

    //查询字段
    public $fieldSearchable = [
        'group_id',
        'goods_name',
        'external_sku_id',
    ];

    protected $fillable = [
        'category_name',
        'type_id',
        'goods_name',
        'goods_id',
        'limit_buy',
        'price_in_fen',
        'sort',
        'external_sku_id',
        'sku_id',
        'group_id',
    ];

    public function getPriceInFenAttribute($value)
    {
        return $value / 100;
    }

    public function goods()
    {
        return $this->hasOne(Goods::class, 'id', 'goods_id');
    }

    public function goodsSku()
    {
        return $this->hasOne(GoodsSku::class, 'id', 'sku_id');
    }
}
