Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0c3d2a64
authored
Jun 16, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix save AdGroup
1 parent
286c5489
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
21 deletions
app/Models/AdGroup.php
app/Models/Keyword.php
app/Models/Pivots/GoalKeyword.php
app/Service/Requests/Direct/GetAdGroups.php
app/Models/AdGroup.php
View file @
0c3d2a6
...
...
@@ -166,8 +166,9 @@ class AdGroup extends Model
static
::
created
(
function
(
AdGroup
$ad_group
)
{
if
(
$ad_group
->
campaign
)
{
$ad_group
->
campaign
->
copyGroupInGoalGroup
();
$ad_group
->
campaign
->
copyGroupInGoalKeyword
();
$ad_group
->
campaign
->
dictionaryCampaigns
()
->
update
([
'synced_need'
=>
Carbon
::
now
(),
]);
}
});
...
...
@@ -176,14 +177,9 @@ class AdGroup extends Model
if
(
GoalAdGroup
::
getPropertiesCopyWithPivot
()
->
first
(
function
(
$property_name
)
use
(
$ad_group
)
{
return
$ad_group
->
{
$property_name
}
!==
$ad_group
->
getOriginal
(
$property_name
);
}))
{
if
(
!
is_null
(
$ad_group
->
campaign_id
)
&&
is_null
(
$ad_group
->
getOriginal
(
'campaign_id'
)))
{
$ad_group
->
campaign
->
copyGroupInGoalGroup
();
$ad_group
->
campaign
->
copyGroupInGoalKeyword
();
}
else
{
$ad_group
->
goalGroups
()
->
has
(
'dictionaryCampaignSynchronized'
)
->
update
(
GoalAdGroup
::
copyPropertyFromMain
(
$ad_group
)
);
}
$ad_group
->
campaign
->
dictionaryCampaigns
()
->
update
([
'synced_need'
=>
Carbon
::
now
(),
]);
}
if
(
self
::
getPropertiesWatch
()
->
first
(
function
(
$property_name
)
use
(
$ad_group
)
{
...
...
app/Models/Keyword.php
View file @
0c3d2a6
...
...
@@ -113,7 +113,9 @@ class Keyword extends Model
static
::
created
(
function
(
Keyword
$keyword
)
{
if
(
$keyword
->
campaign
)
{
$keyword
->
campaign
->
copyGroupInGoalKeyword
();
$keyword
->
campaign
->
dictionaryCampaigns
()
->
update
([
'synced_need'
=>
Carbon
::
now
(),
]);
}
});
...
...
@@ -122,15 +124,9 @@ class Keyword extends Model
if
(
GoalKeyword
::
getPropertiesCopyWithPivot
()
->
first
(
function
(
$property_name
)
use
(
$keyword
)
{
return
$keyword
->
{
$property_name
}
!==
$keyword
->
getOriginal
(
$property_name
);
}))
{
if
(
!
is_null
(
$keyword
->
campaign_id
)
&&
is_null
(
$keyword
->
getOriginal
(
'campaign_id'
)))
{
$keyword
->
campaign
->
copyGroupInGoalKeyword
();
}
else
{
$keyword
->
goalKeywords
()
->
update
(
GoalKeyword
::
copyPropertyFromMain
(
$keyword
)
);
}
$keyword
->
campaign
->
dictionaryCampaigns
()
->
update
([
'synced_need'
=>
Carbon
::
now
(),
]);
}
if
(
self
::
getPropertiesWatch
()
->
first
(
function
(
$property_name
)
use
(
$keyword
)
{
...
...
app/Models/Pivots/GoalKeyword.php
View file @
0c3d2a6
...
...
@@ -124,6 +124,8 @@ class GoalKeyword extends Pivot
static
public
function
updateOrCreateByMain
(
Keyword
$keyword
,
GoalAdGroup
$goalAdGroup
,
DictionaryCampaign
$dictionaryCampaign
)
{
if
(
!
$goalAdGroup
->
getKey
())
\Log
::
debug
(
$goalAdGroup
);
return
GoalKeyword
::
updateOrCreate
([
'dictionary_campaign_id'
=>
$dictionaryCampaign
->
getKey
(),
'dictionary_campaign_external_id'
=>
$dictionaryCampaign
->
external_id
,
...
...
app/Service/Requests/Direct/GetAdGroups.php
View file @
0c3d2a6
...
...
@@ -56,6 +56,8 @@ class GetAdGroups extends DirectRequest
try
{
$external_ids
=
[];
\Log
::
debug
(
$response
);
if
(
!
isset
(
$response
[
'result'
][
'AdGroups'
]))
{
return
;
}
...
...
@@ -83,14 +85,19 @@ class GetAdGroups extends DirectRequest
->
keyBy
(
'external_id'
);
}
\Log
::
debug
(
$campaigns
);
foreach
(
$response
[
'result'
][
'AdGroups'
]
as
$ad_group
)
{
$external_id
=
(
string
)
$ad_group
[
'CampaignId'
];
$campaign
=
$campaigns
->
firstWhere
(
'external_id'
,
$external_id
);
if
(
!
$campaign
)
if
(
!
$campaign
)
{
\Log
::
debug
(
'Not Fround campaign for external_id'
);
\Log
::
debug
(
$external_id
);
continue
;
}
$external_id
=
(
string
)
$ad_group
[
'Id'
];
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment