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 e3a11de7
authored
Jun 18, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Оптимизация выбор переменых
1 parent
9a301988
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
app/Models/Variable.php
app/Service/Requests/Direct/AddAdGroups.php
app/Service/Requests/Direct/AddKeywords.php
app/Models/Variable.php
View file @
e3a11de
...
...
@@ -53,8 +53,13 @@ class Variable extends Model
$variables
=
Variable
::
all
();
}
$values
=
DictionaryCampaignVariable
::
where
(
'dictionary_campaign_id'
,
$dictionary_campaign_id
)
->
whereIn
(
'variable_id'
,
$variables
->
pluck
(
'id'
)
->
toArray
())
->
get
()
->
keyBy
(
'variable_id'
);
foreach
(
$variables
as
$variable
)
{
$dictionaryCampaignVariable
=
$va
riable
->
findValue
(
$dictionary_campaign_id
);
$dictionaryCampaignVariable
=
$va
lues
->
get
(
$variable
->
getKey
()
);
$value
=
(
$dictionaryCampaignVariable
...
...
app/Service/Requests/Direct/AddAdGroups.php
View file @
e3a11de
...
...
@@ -103,10 +103,17 @@ class AddAdGroups extends DirectRequest
$variables
=
Variable
::
all
();
$lists
=
[];
$this
->
setParams
([
'AdGroups'
=>
$this
->
goalAdGroups
->
map
(
function
(
GoalAdGroup
$goalAdGroup
)
use
(
$variables
)
{
'AdGroups'
=>
$this
->
goalAdGroups
->
map
(
function
(
GoalAdGroup
$goalAdGroup
)
use
(
$variables
,
&
$lists
)
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$goalAdGroup
->
dictionary_campaign_id
,
$variables
);
if
(
!
isset
(
$lists
[
$goalKeyword
->
dictionary_campaign_id
]))
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$goalAdGroup
->
dictionary_campaign_id
,
$variables
);
$lists
[
$goalAdGroup
->
dictionary_campaign_id
]
=
$list
;
}
else
{
$list
=
$lists
[
$goalAdGroup
->
dictionary_campaign_id
];
}
$data
=
[
'Name'
=>
StrReplaceByVariables
::
getInstance
(
$goalAdGroup
->
group
->
name
,
$list
)
->
get
(),
...
...
app/Service/Requests/Direct/AddKeywords.php
View file @
e3a11de
...
...
@@ -99,7 +99,7 @@ class AddKeywords extends DirectRequest
$lists
=
[];
$this
->
setParams
([
'Keywords'
=>
$this
->
goalKeywords
->
map
(
function
(
$goalKeyword
)
use
(
$variables
,
$lists
)
{
'Keywords'
=>
$this
->
goalKeywords
->
map
(
function
(
$goalKeyword
)
use
(
$variables
,
&
$lists
)
{
if
(
!
isset
(
$lists
[
$goalKeyword
->
dictionary_campaign_id
]))
{
$list
=
Variable
::
getListVariablesByDictionaryCampaign
(
$goalKeyword
->
dictionary_campaign_id
,
$variables
);
...
...
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