public function clause($key, $method, $model = null)
    {
        $query = null;

        if (! is_null($model)) {
            $appModel = app($model);
            $query = DB::table(app($model)->table);

            if ($this->inBillingCycle) {
                $customer = Customer::retrieve($this->user->meta->stripe_id);
                $stripeSubscription = $customer->subscriptions->retrieve($this->subscription->stripe_id);

                $currentPeriodStart = Carbon::createFromTimestamp($stripeSubscription->current_period_start)->format('Y-m-d h:i:s');
                $currentPeriodEnd = Carbon::createFromTimestamp($stripeSubscription->current_period_end)->format('Y-m-d h:i:s');

                $query = $appModel->where('created_at', '>=', $currentPeriodStart)->where('created_at', '<=', $currentPeriodEnd);
            }
        }

        $clause = $this->config['plans'][$this->subscription->stripe_plan][$key];

        return $method($this->user, $this->subscription, $clause, $query);
    }
public function clause($key, $method, $model = null)
    {
        $query = null;

        if (! is_null($model)) {
            $appModel = app($model);
            $query = DB::table(app($model)->table);

            if ($this->inBillingCycle) {
                $customer = Customer::retrieve($this->user->meta->stripe_id);
                $stripeSubscription = $customer->subscriptions->retrieve($this->subscription->stripe_id);

                $currentPeriodStart = Carbon::createFromTimestamp($stripeSubscription->current_period_start)->format('Y-m-d h:i:s');
                $currentPeriodEnd = Carbon::createFromTimestamp($stripeSubscription->current_period_end)->format('Y-m-d h:i:s');

                $query = $appModel->where('created_at', '>=', $currentPeriodStart)->where('created_at', '<=', $currentPeriodEnd);
            }
        }

        $clause = $this->config['plans'][$this->subscription->stripe_plan][$key];

        return $method($this->user, $this->subscription, $clause, $query);
    }
public function clause ( $ key , $ method , $ model = null ) { $ query = null ; if ( ! is_null ( $ model ) ) { $ appModel = app ( $ model ) ; $ query = DB :: table ( app ( $ model ) -> table ) ; if ( $ this -> inBillingCycle ) { $ customer = Customer :: retrieve ( $ this -> user -> meta -> stripe_id ) ; $ stripeSubscription = $ customer -> subscriptions -> retrieve ( $ this -> subscription -> stripe_id ) ; $ currentPeriodStart = Carbon :: createFromTimestamp ( $ stripeSubscription -> current_period_start ) -> format ( 'Y-m-d h:i:s' ) ; $ currentPeriodEnd = Carbon :: createFromTimestamp ( $ stripeSubscription -> current_period_end ) -> format ( 'Y-m-d h:i:s' ) ; $ query = $ appModel -> where ( 'created_at' , '>=' , $ currentPeriodStart ) -> where ( 'created_at' , '<=' , $ currentPeriodEnd ) ; } } $ clause = $ this -> config [ 'plans' ] [ $ this -> subscription -> stripe_plan ] [ $ key ] ; return $ method ( $ this -> user , $ this -> subscription , $ clause , $ query ) ; }
Subscription clause method
@param  string $key
@param  Closure $method
@param  string $model
@return void
Subscription clause method