PagePlus/Entities/PagePlusMeta.php

30 lines
734 B
PHP
Raw Permalink Normal View History

2024-04-01 12:51:52 +01:00
<?php
namespace Modules\PagePlus\Entities;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Cache;
class PagePlusMeta extends Model
{
protected $fillable = ['page_id', 'key', 'value'];
public function page(): BelongsTo
{
return $this->belongsTo(PagePlus::class, 'page_id');
}
protected static function booted(): void
{
static::saved(function ($meta) {
Cache::forget(PageHelper::cacheKey('meta', $meta->page_id) . '_' . $meta->key);
});
static::deleted(function ($meta) {
Cache::forget(PageHelper::cacheKey('meta', $meta->page_id) . '_' . $meta->key);
});
}
}