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 660327b5
authored
Dec 09, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#21624 Наборы ссылок, связать с рк, обновление
1 parent
e83798dc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
app/Console/Commands/SitelinksDelete.php
app/Models/Pivots/GoalSitelink.php
app/Console/Commands/SitelinksDelete.php
View file @
660327b
...
...
@@ -49,11 +49,23 @@ class SitelinksDelete extends Command
foreach
(
$tokens
as
$token
)
{
$token
->
load
([
'goalSitelinksForExternalNeedDeletedForNotReserveCreate'
'goalSitelinksForExternalNeedDeletedForNotReserveCreate'
=>
function
(
HasMany
$query
)
{
$query
->
join
(
'goal_advertisements'
,
'goal_sitelinks.id'
,
'goal_advertisements.goal_sitelink_id'
)
->
groupBy
(
'goal_sitelinks.id'
)
->
whereNull
(
'goal_advertisements.id'
)
->
select
(
'goal_sitelinks.*'
);
return
$query
;
}
]);
$goalSitelinks
=
$token
->
goalSitelinksForExternalNeedDeletedForNotReserveCreate
;
if
(
!
$goalSitelinks
->
count
())
{
continue
;
}
foreach
(
array_chunk
(
$goalSitelinks
->
pluck
(
'id'
)
->
toArray
(),
100
)
as
$items
)
{
GoalSitelink
::
whereIn
(
'id'
,
$items
)
->
update
([
...
...
app/Models/Pivots/GoalSitelink.php
View file @
660327b
...
...
@@ -59,7 +59,7 @@ class GoalSitelink extends Pivot
*/
public
function
scopeForExternal
(
$query
)
{
return
$query
->
whereNotNull
(
'
external_id'
);
return
$query
->
whereNotNull
(
$query
->
getModel
()
->
getTable
()
.
'.
external_id'
);
}
/**
...
...
@@ -86,7 +86,7 @@ class GoalSitelink extends Pivot
*/
public
function
scopeForNotReserveDelete
(
$query
)
{
return
$query
->
whereNull
(
'
reserve_delete_at'
);
return
$query
->
whereNull
(
$query
->
getModel
()
->
getTable
()
.
'.
reserve_delete_at'
);
}
/**
...
...
@@ -104,7 +104,7 @@ class GoalSitelink extends Pivot
*/
public
function
scopeNeedUpdated
(
$query
)
{
return
$query
->
whereNotNull
(
'
updated_need'
);
return
$query
->
whereNotNull
(
$query
->
getModel
()
->
getTable
()
.
'.
updated_need'
);
}
/**
...
...
@@ -113,13 +113,7 @@ class GoalSitelink extends Pivot
*/
public
function
scopeNeedDeleted
(
$query
)
{
return
$query
->
needUpdated
()
->
whereNotExists
(
function
(
\Illuminate\Database\Query\Builder
$query
)
{
$query
->
select
(
DB
::
raw
(
1
))
->
from
(
'goal_advertisements'
)
->
whereNotNull
(
'goal_advertisements.external_id'
)
->
whereNull
(
'goal_advertisements.deleted_at'
)
->
whereColumn
(
'goal_advertisements.goal_sitelink_external_id'
,
'goal_sitelinks.external_id'
);
});
return
$query
->
needUpdated
();
}
public
function
token
()
...
...
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