feat: increase gallery grid from 4 to 5 columns per row on desktopfeat: increase gallery grid from 4 to 5 columns per row on desktop
This commit is contained in:
56
app/Observers/ArtworkObserver.php
Normal file
56
app/Observers/ArtworkObserver.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Artwork;
|
||||
use App\Services\ArtworkSearchIndexer;
|
||||
|
||||
/**
|
||||
* Syncs artwork documents to Meilisearch on every relevant model event.
|
||||
*
|
||||
* All operations are dispatched to the queue — no blocking calls.
|
||||
*/
|
||||
class ArtworkObserver
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ArtworkSearchIndexer $indexer
|
||||
) {}
|
||||
|
||||
/** New artwork created — index once published and approved. */
|
||||
public function created(Artwork $artwork): void
|
||||
{
|
||||
$this->indexer->index($artwork);
|
||||
}
|
||||
|
||||
/** Artwork updated — covers publish, approval, metadata changes. */
|
||||
public function updated(Artwork $artwork): void
|
||||
{
|
||||
// When soft-deleted, remove from index immediately.
|
||||
if ($artwork->isDirty('deleted_at') && $artwork->deleted_at !== null) {
|
||||
$this->indexer->delete($artwork->id);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->indexer->update($artwork);
|
||||
}
|
||||
|
||||
/** Soft delete — remove from search. */
|
||||
public function deleted(Artwork $artwork): void
|
||||
{
|
||||
$this->indexer->delete($artwork->id);
|
||||
}
|
||||
|
||||
/** Force delete — ensure removal from index. */
|
||||
public function forceDeleted(Artwork $artwork): void
|
||||
{
|
||||
$this->indexer->delete($artwork->id);
|
||||
}
|
||||
|
||||
/** Restored from soft-delete — re-index. */
|
||||
public function restored(Artwork $artwork): void
|
||||
{
|
||||
$this->indexer->index($artwork);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user