File transfer
This commit is contained in:
52
app/Addons/AdvancedAdmin/Models/RoleAuditLog.php
Normal file
52
app/Addons/AdvancedAdmin/Models/RoleAuditLog.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Ball Studios <https://git.balls.studio>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Addons\AdvancedAdmin\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RoleAuditLog extends Model
|
||||
{
|
||||
protected $table = 'addon_role_audit_log';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'actor_id',
|
||||
'action',
|
||||
'target_type',
|
||||
'target_id',
|
||||
'payload',
|
||||
'ip_address',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payload' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Write a structured audit entry.
|
||||
*/
|
||||
public static function record(
|
||||
?int $actorId,
|
||||
string $action,
|
||||
string $targetType = '',
|
||||
?int $targetId = null,
|
||||
array $payload = [],
|
||||
string $ip = ''
|
||||
): void {
|
||||
static::create([
|
||||
'actor_id' => $actorId,
|
||||
'action' => $action,
|
||||
'target_type' => $targetType,
|
||||
'target_id' => $targetId,
|
||||
'payload' => $payload,
|
||||
'ip_address' => $ip ?: request()->ip(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user