where('session_expire', '<', time()) ->where('session_remember', '!=', 1) ->delete(); // Delete notifications that are older than a month but not unread DB::table('notifications') ->where('alert_timestamp', '<', (time() - 109500)) ->where('alert_read', 1) ->delete(); // Get expired premium accounts $expiredPremium = DB::table('premium') ->where('premium_expire', '<', time()) ->get(['user_id']); foreach ($expiredPremium as $premium) { DB::table('premium') ->where('user_id', $premium->user_id) ->delete(); User::construct($premium->user_id) ->isPremium(); }