Price::class, 'threshold' => Price::class, ]; /** * 此优惠券的使用范围 */ public function ranges() { return $this->hasMany(CouponRange::class, 'coupon_id'); } /** * 优惠券的发放任务 */ public function sendTask() { return $this->hasMany(CouponSendTask::class, 'coupon_id'); } /** * 该优惠券下是否有发放任务 * * @return bool */ public function hasSendTask(): bool { return $this->sendTask()->exists(); } public function receiveLog() { return $this->hasMany(UserCoupon::class, 'coupon_id'); } /** * 是否被领取过 * * @return boolean */ public function hasReceived() { return $this->receiveLog()->exists(); } }