hasOne(CouponMain::class, 'id',"coupon_main_id"); } public function business() { return $this->hasOne(Business::class, 'code',"business_code"); } public function account() { return $this->hasOne(Account::class, 'user_code',"user_code"); } public static function getUserOne($userCode,$couponMainId,$couponId) { return self::where( [ ["user_code","=",$userCode], ["coupon_main_id","=",$couponMainId], ["coupon_id","=",$couponId], ] )->find(); } }