app/Console/Commands/SubscriptionExpire.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
        $subscriptions = Subscription::where('status', 1)->whereHas('user')->get();
        foreach ($subscriptions as $subscription) {
            if (getDiffBetweenTwoDate($subscription->start_date, Carbon::now()) > 30) {
                $subscription->update(['status' => 0]);
                User::whereDoesntHave('subscriptions', function ($query) {
                    $query->where('status',1);
                })-> where('id', $subscription->user_id)->update(['subscribed' => 0]);
            }
        }
    }
public function handle ( ) { $ subscriptions = Subscription :: where ( 'status' , 1 ) -> whereHas ( 'user' ) -> get ( ) ; foreach ( $ subscriptions as $ subscription ) { if ( getDiffBetweenTwoDate ( $ subscription -> start_date , Carbon :: now ( ) ) > 30 ) { $ subscription -> update ( [ 'status' => 0 ] ) ; User :: whereDoesntHave ( 'subscriptions' , function ( $ query ) { $ query -> where ( 'status' , 1 ) ; } ) -> where ( 'id' , $ subscription -> user_id ) -> update ( [ 'subscribed' => 0 ] ) ; } } }
Execute the console command.
Execute the console command .