with($with)->where('assemble_product_id', '=', $assemble_product_id)->find(); } public function active() { return $this->belongsTo('app\\common\\model\\plus\\assemble\\Active', 'assemble_activity_id', 'assemble_activity_id'); } public function product() { return $this->belongsTo('app\\common\\model\\product\\Product', 'product_id', 'product_id'); } /** *关联商品规格表 */ public function assembleSku() { return $this->hasMany('app\\common\\model\\plus\\assemble\\AssembleSku', 'assemble_product_id', 'assemble_product_id'); } /** * 关联供应商 */ public function supplier() { return $this->hasMany('app\\common\\model\\supplier\\Supplier', 'shop_supplier_id', 'shop_supplier_id'); } /** * 商品ID是否存在 */ public static function isExistProductId($productId) { /*return (new static)->where('product_id', '=', $productId) ->where('is_delete', '=', 0) ->value('assemble_product_id');*/ return (new static)->alias('a')->where('a.product_id', '=', $productId) ->join('assemble_activity aa', 'aa.assemble_activity_id=a.assemble_activity_id') ->where('aa.is_delete', '=', 0) ->where('a.is_delete', '=', 0) ->value('a.assemble_product_id'); } }