2022-05-29 17:07:54 -04:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Events;
|
2022-05-29 17:07:54 -04:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Models\ActivityLog;
|
2022-05-29 17:07:54 -04:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2025-09-24 13:34:19 +02:00
|
|
|
use Illuminate\Support\Str;
|
2022-05-29 17:07:54 -04:00
|
|
|
|
|
|
|
|
class ActivityLogged extends Event
|
|
|
|
|
{
|
2024-11-22 09:27:57 +01:00
|
|
|
public function __construct(public ActivityLog $model) {}
|
2022-05-29 17:07:54 -04:00
|
|
|
|
|
|
|
|
public function is(string $event): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->model->event === $event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function actor(): ?Model
|
|
|
|
|
{
|
|
|
|
|
return $this->isSystem() ? null : $this->model->actor;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public function isServerEvent(): bool
|
2022-05-29 17:07:54 -04:00
|
|
|
{
|
|
|
|
|
return Str::startsWith($this->model->event, 'server:');
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public function isSystem(): bool
|
2022-05-29 17:07:54 -04:00
|
|
|
{
|
|
|
|
|
return is_null($this->model->actor_id);
|
|
|
|
|
}
|
|
|
|
|
}
|