public function renew()
    {
        if ($this->isEnded() and $this->isCanceled()) {
            throw new LogicException(
                'Unable to renew canceled ended subscription.'
            );
        }

        $subscription = $this;

        DB::transaction(function () use ($subscription) {
            // Clear usage data
            $usageManager = new SubscriptionUsageManager($subscription);
            $usageManager->clear();

            // Renew period
            $subscription->setNewPeriod();
            $subscription->canceled_at = null;
            $subscription->save();
        });

        event(new SubscriptionRenewed($this));

        return $this;
    }
public function renew()
    {
        if ($this->isEnded() and $this->isCanceled()) {
            throw new LogicException(
                'Unable to renew canceled ended subscription.'
            );
        }

        $subscription = $this;

        DB::transaction(function () use ($subscription) {
            // Clear usage data
            $usageManager = new SubscriptionUsageManager($subscription);
            $usageManager->clear();

            // Renew period
            $subscription->setNewPeriod();
            $subscription->canceled_at = null;
            $subscription->save();
        });

        event(new SubscriptionRenewed($this));

        return $this;
    }
public function renew ( ) { if ( $ this -> isEnded ( ) and $ this -> isCanceled ( ) ) { throw new LogicException ( 'Unable to renew canceled ended subscription.' ) ; } $ subscription = $ this ; DB :: transaction ( function ( ) use ( $ subscription ) { // Clear usage data $ usageManager = new SubscriptionUsageManager ( $ subscription ) ; $ usageManager -> clear ( ) ; // Renew period $ subscription -> setNewPeriod ( ) ; $ subscription -> canceled_at = null ; $ subscription -> save ( ) ; } ) ; event ( new SubscriptionRenewed ( $ this ) ) ; return $ this ; }
Renew subscription period.

@throws  \LogicException
@return  $this
Renew subscription period .