where('product_id', $marketId)->find(); if($rows){ return $rows->delete(); }else{ return self::create(['user_id'=>$uid, 'product_id'=>$marketId]); } } //用户 public function users() { return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0); } }