-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syncing & Queued Deletes #3
Conversation
…n a 'parent' models publishing status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly this all looks quite reasonable to me, barring that nestedPluck()
method
/** | ||
* @return Collection<Publishable&Model> | ||
*/ | ||
protected function nestedPluck(string $relation): Collection | ||
{ | ||
$this->loadMissing($relation); | ||
|
||
$models = [$this]; | ||
|
||
$relations = explode('.', $relation); | ||
|
||
while ($part = array_shift($relations)) { | ||
$results = []; | ||
|
||
foreach ($models as $model) { | ||
$related = $model->{$part}; | ||
|
||
if ($related instanceof Model) { | ||
$results[] = $related; | ||
|
||
continue; | ||
} | ||
|
||
if ($related instanceof Arrayable) { | ||
foreach ($related as $item) { | ||
$results[] = $item; | ||
} | ||
} | ||
} | ||
|
||
$models = $results; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe i'm misunderstanding, but, i'm not sure if this method is needed, last i remember pluck supports the dot notation doesn't it? ie: ->pluck('relation.property')
Summary
In order for drafted content to be able to have "dependent" content, we add the notion if syncing and queued deleted.
Status is always synced to dependents when content is saved.
Deletes are queued on dependent content until the parent is published.
Tests