Skip to content

Commit

Permalink
Merge branch 'main' into 11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurt Friars committed Feb 7, 2025
2 parents 7372cc9 + 1c06e6f commit 008d297
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Concerns/SyncsPublishing.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ public static function bootSyncsPublishing()

public function syncPublishingToDependents(): void
{
$this->publishingDependents()
->map(fn (string $relation) => $this->nestedPluck($relation))
->flatten()
$this->getPublishingDependents()
->each(fn (Publishable&Model $model) => $model->syncPublishingFrom($this));
}

/**
* @return Collection<Publishable&Model>
*/
public function getPublishingDependents(): Collection
{
return $this->publishingDependents()
->map(fn (string $relation) => $this->nestedPluck($relation))
->flatten();
}

public function publishingDependents(): Collection
{
if (property_exists($this, 'publishingDependents')) {
Expand Down
7 changes: 7 additions & 0 deletions src/Contracts/Publishable.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ public function syncPublishingFrom(Publishable&Model $from): void;
*/
public function publishingDependents(): Collection;

/**
* Resolve the publishing dependent models
*
* @return Collection<Publishable&Model>
*/
public function getPublishingDependents(): Collection;

/**
* Queue the model for deletion if it's owner is not published
*/
Expand Down

0 comments on commit 008d297

Please sign in to comment.