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

[PLA-2023] Sync attribute when creating or updating #276

Merged
merged 2 commits into from
Oct 21, 2024
Merged
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
18 changes: 18 additions & 0 deletions src/Models/Laravel/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Enjin\Platform\Models\Laravel;

use Enjin\Platform\Database\Factories\AttributeFactory;
use Enjin\Platform\Jobs\SyncMetadata;
use Enjin\Platform\Models\BaseModel;
use Enjin\Platform\Models\Laravel\Traits\Attribute as AttributeMethods;
use Enjin\Platform\Models\Laravel\Traits\EagerLoadSelectFields;
Expand Down Expand Up @@ -38,6 +39,23 @@ class Attribute extends BaseModel
*/
protected $guarded = [];

public static function boot(): void
{
parent::boot();

static::created(function ($model): void {
if ($model->key == '0x757269') {
SyncMetadata::dispatch($model->id);
}
});

static::updated(function ($model): void {
if ($model->key == '0x757269') {
SyncMetadata::dispatch($model->id);
}
});
}

/**
* The attribute key as String.
*/
Expand Down
Loading