bind('Goods', function ($goodsManager, $attributes = []) { if(\YunShop::isApi()){ //前台 return new Goods($attributes); }else{ //后台 return new \app\backend\modules\goods\models\Goods($attributes); } }); $this->bind('GoodsOption', function ($goodsManager, $attributes = []) { if(\YunShop::isApi()){ //前台 return new GoodsOption($attributes); }else{ //后台 return new \app\backend\modules\goods\models\GoodsOption($attributes); } }); $this->bind('GoodsSale', function ($goodsManager, $attributes = []) { if(\YunShop::isApi()){ //前台 return new Sale($attributes); }else{ //后台 return new \app\backend\modules\goods\models\Sale($attributes); } }); } }