Test that a deleted backup makes an audit log entry

This commit is contained in:
Dane Everitt 2021-07-11 12:15:39 -07:00
parent d33522c857
commit d3e3b1db38
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 83 additions and 2 deletions

View file

@ -69,6 +69,7 @@ class AuditLog extends Model
* @var string[]
*/
protected $casts = [
'is_system' => 'bool',
'device' => 'array',
'metadata' => 'array',
];

View file

@ -21,6 +21,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property \Carbon\CarbonImmutable $updated_at
* @property \Carbon\CarbonImmutable|null $deleted_at
* @property \Pterodactyl\Models\Server $server
* @property \Pterodactyl\Models\AuditLog[] $audits
*/
class Backup extends Model
{
@ -98,4 +99,14 @@ class Backup extends Model
{
return $this->belongsTo(Server::class);
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function audits()
{
return $this->hasMany(AuditLog::class, 'metadata->backup_uuid', 'uuid')
->where('action', 'LIKE', 'server:backup.%');
// ->where('metadata->backup_uuid', $this->uuid);
}
}