hasOne('app\common\models\Goods','id','goods_id'); } public function goodsDiscount() { return $this->hasMany(GoodsDiscount::class, 'goods_id', 'goods_id'); } public function goodsOption() { return $this->hasOne('app\common\models\GoodsOption','id','goods_option_id'); } public function delCategory($goods_id) { return $this->where(['goods_id' => $goods_id]) ->delete(); } public static function boot() { parent::boot(); //注册观察者 static::observe(new GoodsCategoryObserver); } }