From 0cc6f843e6f612486fdecc199e6d760d3a9e7c15 Mon Sep 17 00:00:00 2001 From: Dean Blackborough Date: Sat, 24 Jun 2023 16:25:34 +0100 Subject: [PATCH] Fix - Move the cache clear and change the created at --- app/Jobs/MigrateBudgetItemsToBudgetPro.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Jobs/MigrateBudgetItemsToBudgetPro.php b/app/Jobs/MigrateBudgetItemsToBudgetPro.php index dfd73d05..34d6ca82 100644 --- a/app/Jobs/MigrateBudgetItemsToBudgetPro.php +++ b/app/Jobs/MigrateBudgetItemsToBudgetPro.php @@ -125,7 +125,7 @@ public function handle() $budget_pro_model->end_date = $item->end_date; $budget_pro_model->disabled = $item->disabled; $budget_pro_model->frequency = $item->frequency; - $budget_pro_model->created_at = 'NOW()'; + $budget_pro_model->created_at = $item_model->created_at; $budget_pro_model->save(); } @@ -134,20 +134,20 @@ public function handle() $resource->data = $budget_resource_data; $resource->save(); } - - $cache_clear_payload = (new \App\Cache\JobPayload()) - ->setGroupKey(\App\Cache\KeyGroup::RESOURCE_DELETE) - ->setRouteParameters([ - 'resource_type_id' => $budget_pro_resource_type_id, - 'resource_id' => $budget_pro_resource_id - ]) - ->setUserId($this->user_id); - - ClearCache::dispatchSync($cache_clear_payload->payload()); }); } catch (\Exception) { $this->fail(new \Exception('Failed to create all the items or save the resource data')); } + + $cache_clear_payload = (new \App\Cache\JobPayload()) + ->setGroupKey(\App\Cache\KeyGroup::RESOURCE_DELETE) + ->setRouteParameters([ + 'resource_type_id' => $budget_pro_resource_type_id, + 'resource_id' => $budget_pro_resource_id + ]) + ->setUserId($this->user_id); + + ClearCache::dispatchSync($cache_clear_payload->payload()); } public function fetchBudgetItems(int $resource_id): array