From a6963ad8026a7d7f31fc6fc6423e8eeba4022de8 Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:25:36 +0100 Subject: [PATCH] Remove Deprecated `PHPDoc` comment & `AuditLog` Model (#997) * Remove missleading deprecation, you cant use can/cannot on apikeys * Remove unused `AuditLog` Model --- app/Models/AuditLog.php | 87 ------------------- app/Models/Backup.php | 1 - .../Api/Application/BaseTransformer.php | 2 - ...5_02_11_181129_remove_audit_logs_table.php | 23 +++++ 4 files changed, 23 insertions(+), 90 deletions(-) delete mode 100644 app/Models/AuditLog.php create mode 100644 database/migrations/2025_02_11_181129_remove_audit_logs_table.php diff --git a/app/Models/AuditLog.php b/app/Models/AuditLog.php deleted file mode 100644 index ebd8ad5a5..000000000 --- a/app/Models/AuditLog.php +++ /dev/null @@ -1,87 +0,0 @@ - 'required|uuid', - 'action' => 'required|string|max:255', - 'subaction' => 'nullable|string|max:255', - 'device' => 'array', - 'device.ip_address' => 'ip', - 'device.user_agent' => 'string', - 'metadata' => 'array', - ]; - - protected $guarded = [ - 'id', - 'created_at', - ]; - - protected function casts(): array - { - return [ - 'is_system' => 'bool', - 'device' => 'array', - 'metadata' => 'array', - 'created_at' => 'immutable_datetime', - ]; - } - - public function user(): BelongsTo - { - return $this->belongsTo(User::class); - } - - public function server(): BelongsTo - { - return $this->belongsTo(Server::class); - } - - /** - * Creates a new AuditLog model and returns it, attaching device information and the - * currently authenticated user if available. This model is not saved at this point, so - * you can always make modifications to it as needed before saving. - * - * @deprecated - */ - public static function instance(string $action, array $metadata, bool $isSystem = false): self - { - /** @var ?Request $request */ - $request = Container::getInstance()->make('request'); - if ($isSystem || !$request instanceof Request) { - $request = null; - } - - return (new self())->fill([ - 'uuid' => Uuid::uuid4()->toString(), - 'is_system' => $isSystem, - 'user_id' => ($request && $request->user()) ? $request->user()->id : null, - 'server_id' => null, - 'action' => $action, - 'device' => $request ? [ - 'ip_address' => $request->getClientIp() ?? '127.0.0.1', - 'user_agent' => $request->userAgent() ?? '', - ] : [], - 'metadata' => $metadata, - ]); - } -} diff --git a/app/Models/Backup.php b/app/Models/Backup.php index 58f8da2eb..5fb1094cf 100644 --- a/app/Models/Backup.php +++ b/app/Models/Backup.php @@ -27,7 +27,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property \Carbon\CarbonImmutable $updated_at * @property \Carbon\CarbonImmutable|null $deleted_at * @property \App\Models\Server $server - * @property \App\Models\AuditLog[] $audits */ class Backup extends Model implements Validatable { diff --git a/app/Transformers/Api/Application/BaseTransformer.php b/app/Transformers/Api/Application/BaseTransformer.php index 397158a13..bc9353566 100644 --- a/app/Transformers/Api/Application/BaseTransformer.php +++ b/app/Transformers/Api/Application/BaseTransformer.php @@ -59,8 +59,6 @@ abstract class BaseTransformer extends TransformerAbstract * Determine if the API key loaded onto the transformer has permission * to access a different resource. This is used when including other * models on a transformation request. - * - * @deprecated — prefer $user->can/cannot methods */ protected function authorize(string $resource): bool { diff --git a/database/migrations/2025_02_11_181129_remove_audit_logs_table.php b/database/migrations/2025_02_11_181129_remove_audit_logs_table.php new file mode 100644 index 000000000..105b4750f --- /dev/null +++ b/database/migrations/2025_02_11_181129_remove_audit_logs_table.php @@ -0,0 +1,23 @@ +