app/Console/Commands/AcademySubscriptionExpire.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle()
    {
         $subscriptions = AcadSubscription::where('status', 1)
            ->whereHas('user')
            ->whereDate('end_date', '<', date('Y-m-d'))
            ->get();
        foreach ($subscriptions as $subscription) {
            $subscription->update(['status' => 0]);
            User::whereDoesntHave('AcademySubscriptions', function ($query) {
                $query->where('status', 1);
            })
                ->where('id', $subscription->user_id)
                ->update(['academysubscribed' => 0]);
        }
    }
public function handle ( ) { $ subscriptions = AcadSubscription :: where ( 'status' , 1 ) -> whereHas ( 'user' ) -> whereDate ( 'end_date' , '<' , date ( 'Y-m-d' ) ) -> get ( ) ; foreach ( $ subscriptions as $ subscription ) { $ subscription -> update ( [ 'status' => 0 ] ) ; User :: whereDoesntHave ( 'AcademySubscriptions' , function ( $ query ) { $ query -> where ( 'status' , 1 ) ; } ) -> where ( 'id' , $ subscription -> user_id ) -> update ( [ 'academysubscribed' => 0 ] ) ; } }
Execute the console command.
Execute the console command .