Ensure we can properly create an activity log entry; always return soft-deleted models
This commit is contained in:
parent
f1c1699994
commit
09832cc558
5 changed files with 106 additions and 29 deletions
37
app/Events/ActivityLogged.php
Normal file
37
app/Events/ActivityLogged.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Events;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ActivityLogged extends Event
|
||||
{
|
||||
public ActivityLog $model;
|
||||
|
||||
public function __construct(ActivityLog $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function is(string $event): bool
|
||||
{
|
||||
return $this->model->event === $event;
|
||||
}
|
||||
|
||||
public function actor(): ?Model
|
||||
{
|
||||
return $this->isSystem() ? null : $this->model->actor;
|
||||
}
|
||||
|
||||
public function isServerEvent()
|
||||
{
|
||||
return Str::startsWith($this->model->event, 'server:');
|
||||
}
|
||||
|
||||
public function isSystem()
|
||||
{
|
||||
return is_null($this->model->actor_id);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue