Commit 92fc498d by Vladislav

Fix save update external key after add in api

1 parent 99aea40d
...@@ -6,7 +6,6 @@ use App\Jobs\ProcessCallLimitedAPI; ...@@ -6,7 +6,6 @@ use App\Jobs\ProcessCallLimitedAPI;
use App\Models\Campaigns; use App\Models\Campaigns;
use App\Models\Pivots\DictionaryCampaign; use App\Models\Pivots\DictionaryCampaign;
use App\Models\Pivots\GoalAdGroup; use App\Models\Pivots\GoalAdGroup;
use App\Models\Pivots\GoalKeyword;
use App\Models\Variable; use App\Models\Variable;
use App\Service\Contract\APIRequest; use App\Service\Contract\APIRequest;
use App\Service\Requests\DirectRequest; use App\Service\Requests\DirectRequest;
...@@ -74,9 +73,6 @@ class AddAdGroups extends DirectRequest ...@@ -74,9 +73,6 @@ class AddAdGroups extends DirectRequest
$goalAdGroup = $this->goalAdGroups->get($key); $goalAdGroup = $this->goalAdGroups->get($key);
$goalAdGroup = GoalKeyword::find($goalAdGroup->id);
if ($goalAdGroup) {
$goalAdGroup->update([ $goalAdGroup->update([
'external_id' => $external_id, 'external_id' => $external_id,
'external_upload_at' => Carbon::now(), 'external_upload_at' => Carbon::now(),
...@@ -85,7 +81,6 @@ class AddAdGroups extends DirectRequest ...@@ -85,7 +81,6 @@ class AddAdGroups extends DirectRequest
$goalAdGroup->goalKeywords()->update([ $goalAdGroup->goalKeywords()->update([
'goal_ad_group_external_id' => $external_id, 'goal_ad_group_external_id' => $external_id,
]); ]);
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Service\Requests\Direct; namespace App\Service\Requests\Direct;
use App\Jobs\ProcessCallLimitedAPI; use App\Jobs\ProcessCallLimitedAPI;
use App\Models\Pivots\GoalKeyword;
use App\Models\Variable; use App\Models\Variable;
use App\Service\Contract\APIRequest; use App\Service\Contract\APIRequest;
use App\Service\Requests\DirectRequest; use App\Service\Requests\DirectRequest;
...@@ -71,6 +72,19 @@ class AddKeywords extends DirectRequest ...@@ -71,6 +72,19 @@ class AddKeywords extends DirectRequest
$goalKeyword = $this->goalKeywords[$key]; $goalKeyword = $this->goalKeywords[$key];
$goalKeyword = GoalKeyword::find($goalKeyword->id);
if ($goalKeyword) {
$goalKeyword->update([
'external_id' => $external_id,
'external_upload_at' => Carbon::now(),
]);
$goalKeyword->goalKeywords()->update([
'goal_ad_group_external_id' => $external_id,
]);
}
$goalKeyword->update([ $goalKeyword->update([
'external_id' => $external_id, 'external_id' => $external_id,
'external_upload_at' => Carbon::now(), 'external_upload_at' => Carbon::now(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!