Laravel 10 (#4706)
This commit is contained in:
parent
ad4ddc6300
commit
1d38b4f0e2
136 changed files with 1735 additions and 2008 deletions
|
@ -3,7 +3,6 @@
|
|||
namespace Pterodactyl\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use LogicException;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Pterodactyl\Events\ActivityLogged;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
@ -124,7 +123,7 @@ class ActivityLog extends Model
|
|||
public function prunable()
|
||||
{
|
||||
if (is_null(config('activity.prune_days'))) {
|
||||
throw new LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.');
|
||||
throw new \LogicException('Cannot prune activity logs: no "prune_days" configuration value is set.');
|
||||
}
|
||||
|
||||
return static::where('timestamp', '<=', Carbon::now()->subDays(config('activity.prune_days')));
|
||||
|
|
|
@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|||
* @property array|null $allowed_ips
|
||||
* @property string|null $memo
|
||||
* @property \Illuminate\Support\Carbon|null $last_used_at
|
||||
* @property \Illuminate\Support\Carbon|null $expires_at
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property int $r_servers
|
||||
|
@ -97,6 +98,10 @@ class ApiKey extends Model
|
|||
protected $casts = [
|
||||
'allowed_ips' => 'array',
|
||||
'user_id' => 'int',
|
||||
'last_used_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
self::CREATED_AT => 'datetime',
|
||||
self::UPDATED_AT => 'datetime',
|
||||
'r_' . AdminAcl::RESOURCE_USERS => 'int',
|
||||
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int',
|
||||
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
|
||||
|
@ -117,6 +122,7 @@ class ApiKey extends Model
|
|||
'allowed_ips',
|
||||
'memo',
|
||||
'last_used_at',
|
||||
'expires_at',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -137,6 +143,7 @@ class ApiKey extends Model
|
|||
'allowed_ips' => 'nullable|array',
|
||||
'allowed_ips.*' => 'string',
|
||||
'last_used_at' => 'nullable|date',
|
||||
'expires_at' => 'nullable|date',
|
||||
'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3',
|
||||
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3',
|
||||
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
|
||||
|
@ -148,12 +155,6 @@ class ApiKey extends Model
|
|||
'r_' . AdminAcl::RESOURCE_SERVERS => 'integer|min:0|max:3',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
self::CREATED_AT,
|
||||
self::UPDATED_AT,
|
||||
'last_used_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the user this token is assigned to.
|
||||
*/
|
||||
|
|
|
@ -43,10 +43,7 @@ class Backup extends Model
|
|||
'is_locked' => 'bool',
|
||||
'ignored_files' => 'array',
|
||||
'bytes' => 'int',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'completed_at',
|
||||
'completed_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Models\Filters;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Spatie\QueryBuilder\Filters\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
|
@ -17,7 +16,7 @@ class AdminServerFilter implements Filter
|
|||
public function __invoke(Builder $query, $value, string $property)
|
||||
{
|
||||
if ($query->getQuery()->from !== 'servers') {
|
||||
throw new BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.');
|
||||
throw new \BadMethodCallException('Cannot use the AdminServerFilter against a non-server model.');
|
||||
}
|
||||
$query
|
||||
->select('servers.*')
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Models\Filters;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\QueryBuilder\Filters\Filter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
@ -25,7 +24,7 @@ class MultiFieldServerFilter implements Filter
|
|||
public function __invoke(Builder $query, $value, string $property)
|
||||
{
|
||||
if ($query->getQuery()->from !== 'servers') {
|
||||
throw new BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.');
|
||||
throw new \BadMethodCallException('Cannot use the MultiFieldServerFilter against a non-server model.');
|
||||
}
|
||||
|
||||
if (preg_match(self::IPV4_REGEX, $value) || preg_match('/^:\d{1,5}$/', $value)) {
|
||||
|
|
|
@ -71,14 +71,8 @@ class Schedule extends Model
|
|||
'is_active' => 'boolean',
|
||||
'is_processing' => 'boolean',
|
||||
'only_when_online' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Columns to mutate to a date.
|
||||
*/
|
||||
protected $dates = [
|
||||
'last_run_at',
|
||||
'next_run_at',
|
||||
'last_run_at' => 'datetime',
|
||||
'next_run_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $attributes = [
|
||||
|
|
|
@ -139,11 +139,6 @@ class Server extends Model
|
|||
*/
|
||||
protected $with = ['allocation'];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*/
|
||||
protected $dates = [self::CREATED_AT, self::UPDATED_AT, 'deleted_at', 'installed_at'];
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*/
|
||||
|
@ -193,6 +188,10 @@ class Server extends Model
|
|||
'database_limit' => 'integer',
|
||||
'allocation_limit' => 'integer',
|
||||
'backup_limit' => 'integer',
|
||||
self::CREATED_AT => 'datetime',
|
||||
self::UPDATED_AT => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'installed_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,10 +23,8 @@ class TaskLog extends Model
|
|||
'id' => 'integer',
|
||||
'task_id' => 'integer',
|
||||
'run_status' => 'integer',
|
||||
'run_time' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*/
|
||||
protected $dates = ['run_time', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
|
|
@ -134,10 +134,9 @@ class User extends Model implements
|
|||
'root_admin' => 'boolean',
|
||||
'use_totp' => 'boolean',
|
||||
'gravatar' => 'boolean',
|
||||
'totp_authenticated_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $dates = ['totp_authenticated_at'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue