Skip to content
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

fix(bug):(LAR-142) deleting activities after a specific model #271

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/Models/Article.php
StevyMarlino marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ final class Article extends Model implements HasMedia, ReactableInterface, Sitem
'is_pinned' => 'boolean',
];

protected static function booted(): void
{
Article::deleting(function ($article): void {
$article->activities()->delete();
});
}

protected bool $removeViewsOnDelete = true;

public function getRouteKeyName(): string
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ final class Discussion extends Model implements ReactableInterface, ReplyInterfa

protected bool $removeViewsOnDelete = true;

protected static function booted(): void
{
Discussion::deleting(function ($discussion): void {
$discussion->activities()->delete();
});
}

public function newEloquentBuilder($query): DiscussionQueryBuilder
{
return new DiscussionQueryBuilder($query);
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ final class Reply extends Model implements ReactableInterface, ReplyInterface, S
'body',
];

protected static function booted(): void
{
Reply::deleting(function ($reply): void {
$reply->activities()->delete();
});
}

public function subject(): int
{
return $this->id;
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ final class Thread extends Model implements Feedable, ReactableInterface, ReplyI

protected bool $removeViewsOnDelete = true;

protected static function booted(): void
{
Thread::deleting(function ($thread): void {
$thread->activities()->delete();
});
}

public function getRouteKeyName(): string
{
return 'slug';
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading