mirror of
https://github.com/pelican-dev/panel.git
synced 2026-07-16 04:03:50 +03:00
27 lines
654 B
PHP
27 lines
654 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Traits;
|
||
|
|
|
||
|
|
use App\Observers\AdminActivityObserver;
|
||
|
|
|
||
|
|
trait HasAdminActivityLogging
|
||
|
|
{
|
||
|
|
public static function bootHasAdminActivityLogging(): void
|
||
|
|
{
|
||
|
|
$observer = new AdminActivityObserver();
|
||
|
|
|
||
|
|
static::created(fn ($model) => $observer->created($model));
|
||
|
|
static::updated(fn ($model) => $observer->updated($model));
|
||
|
|
static::deleted(fn ($model) => $observer->deleted($model));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getAdminActivityName(): string
|
||
|
|
{
|
||
|
|
if (isset($this->attributes['name'])) {
|
||
|
|
return (string) $this->attributes['name'];
|
||
|
|
}
|
||
|
|
|
||
|
|
return (string) $this->getKey();
|
||
|
|
}
|
||
|
|
}
|