function deleteCachedItemsFromPastPlans($plan_id) { $caches = PlanCache::get(); // check each cache item if it is outdated foreach ($caches as $cache) { if ($cache->plan->date < Carbon::now() && $cache->plan->id != $plan_id) { $cache->delete(); } } }