35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphPivot;
|
|
|
|
/**
|
|
* @property integer $id Id of the news.
|
|
* @property \App\Models\News $news_id Name of the news.
|
|
* @property \App\Models\NewsCategory|\App\Models\NewsTag $newsable_id Name of the category or tag.
|
|
* @property class-string<static> $newsable_type Class of the category or tag.
|
|
* @property-read \Carbon\Carbon $created_at Created date of the news.
|
|
* @property-read \Carbon\Carbon $updated_at Updated date of the news.
|
|
*/
|
|
class Newsable extends MorphPivot
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
protected $table = 'newsables';
|
|
|
|
/**
|
|
* Perform any actions required after the model boots.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function booted(): void
|
|
{
|
|
static::created(fn() => News::resetCache());
|
|
static::updated(fn() => News::resetCache());
|
|
static::deleted(fn() => News::resetCache());
|
|
}
|
|
}
|