layer-chicken/app/Observers/FeedObserver.php

58 lines
1.1 KiB
PHP

<?php
namespace App\Observers;
use App\Models\Feed;
use Illuminate\Support\Facades\Cache;
class FeedObserver
{
/**
* Handle events after any change that should invalidate feed cache.
*/
protected function clearFeedCache(): void
{
Cache::store('redis')->forget('feeds_with_unit_for_purchase_form');
}
/**
* Handle the Feed "created" event.
*/
public function created(Feed $feed): void
{
$this->clearFeedCache();
}
/**
* Handle the Feed "updated" event.
*/
public function updated(Feed $feed): void
{
$this->clearFeedCache();
}
/**
* Handle the Feed "deleted" event.
*/
public function deleted(Feed $feed): void
{
$this->clearFeedCache();
}
/**
* Handle the Feed "restored" event.
*/
public function restored(Feed $feed): void
{
$this->clearFeedCache();
}
/**
* Handle the Feed "force deleted" event.
*/
public function forceDeleted(Feed $feed): void
{
$this->clearFeedCache();
}
}