Remove Deprecated PHPDoc comment & AuditLog Model (#997)

* Remove missleading deprecation, you cant use can/cannot on apikeys

* Remove unused `AuditLog` Model
This commit is contained in:
MartinOscar 2025-02-11 19:25:36 +01:00 committed by GitHub
parent d48cf6b722
commit a6963ad802
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 90 deletions

View File

@ -1,87 +0,0 @@
<?php
namespace App\Models;
use App\Contracts\Validatable;
use App\Traits\HasValidation;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Ramsey\Uuid\Uuid;
use Illuminate\Http\Request;
use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @deprecated this class will be dropped in a future version, use the activity log
*/
class AuditLog extends Model implements Validatable
{
use HasFactory;
use HasValidation;
public const UPDATED_AT = null;
public static array $validationRules = [
'uuid' => '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,
]);
}
}

View File

@ -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
{

View File

@ -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
{

View File

@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::dropIfExists('audit_logs');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Not needed
}
};