/home/techb158/immovalet.com/platform/plugins/blog/src/Models
Edit: /home/techb158/immovalet.com/platform/plugins/blog/src/Models/Post.php (2487B)
BaseStatusEnum::class,
];
/**
* @deprecated
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class)->withDefault();
}
/**
* @return BelongsToMany
*/
public function tags(): BelongsToMany
{
return $this->belongsToMany(Tag::class, 'post_tags');
}
/**
* @return BelongsToMany
*/
public function categories(): BelongsToMany
{
return $this->belongsToMany(Category::class, 'post_categories');
}
/**
* @return Category
*/
public function getFirstCategoryAttribute()
{
return $this->categories->first();
}
/**
* @return MorphTo
*/
public function author(): MorphTo
{
return $this->morphTo();
}
protected static function boot()
{
parent::boot();
static::deleting(function (Post $post) {
$post->categories()->detach();
$post->tags()->detach();
});
}
}