Skip to content

Commit

Permalink
chore: update app for laravel 11
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Penner <[email protected]>
  • Loading branch information
matthewpi committed Oct 21, 2024
1 parent d65d55d commit bd8ac59
Show file tree
Hide file tree
Showing 37 changed files with 313 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function handle()

collect($files)->each(function (\SplFileInfo $file) {
$lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
if ((int) $lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file->getPath());
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file->getFilename()]));
}
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pterodactyl\Models;

use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* Pterodactyl\Models\Allocation.
Expand Down Expand Up @@ -40,6 +41,9 @@
*/
class Allocation extends Model
{
/** @use HasFactory<\Database\Factories\AllocationFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Webmozart\Assert\Assert;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* Pterodactyl\Models\ApiKey.
Expand Down Expand Up @@ -61,6 +62,9 @@
*/
class ApiKey extends Model
{
/** @use HasFactory<\Database\Factories\ApiKeyFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand All @@ -26,6 +27,8 @@
*/
class Backup extends Model
{
/** @use HasFactory<\Database\Factories\BackupFactory> */
use HasFactory;
use SoftDeletes;

public const RESOURCE_NAME = 'backup';
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Pterodactyl\Contracts\Extensions\HashidsInterface;

/**
Expand All @@ -22,6 +23,9 @@
*/
class Database extends Model
{
/** @use HasFactory<\Database\Factories\DatabaseFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/DatabaseHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand All @@ -19,6 +20,9 @@
*/
class DatabaseHost extends Model
{
/** @use HasFactory<\Database\Factories\DatabaseHostFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Egg.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand Down Expand Up @@ -48,6 +49,9 @@
*/
class Egg extends Model
{
/** @use HasFactory<\Database\Factories\EggFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/EggVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand All @@ -27,6 +28,9 @@
*/
class EggVariable extends Model
{
/** @use HasFactory<\Database\Factories\EggVariableFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pterodactyl\Models;

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;

/**
Expand All @@ -16,6 +17,9 @@
*/
class Location extends Model
{
/** @use HasFactory<\Database\Factories\LocationFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
3 changes: 0 additions & 3 deletions app/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Pterodactyl\Exceptions\Model\DataValidationException;
use Illuminate\Database\Eloquent\Model as IlluminateModel;
use Illuminate\Contracts\Validation\Factory as ValidationFactory;

abstract class Model extends IlluminateModel
{
use HasFactory;

/**
* Set to true to return immutable Carbon date instances from the model.
*/
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Nest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pterodactyl\Models;

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand All @@ -17,6 +18,9 @@
*/
class Nest extends Model
{
/** @use HasFactory<\Database\Factories\NestFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;

/**
Expand Down Expand Up @@ -41,6 +42,8 @@
*/
class Node extends Model
{
/** @use HasFactory<\Database\Factories\NodeFactory> */
use HasFactory;
use Notifiable;

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Models/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Pterodactyl\Contracts\Extensions\HashidsInterface;

/**
Expand All @@ -31,6 +32,9 @@
*/
class Schedule extends Model
{
/** @use HasFactory<\Database\Factories\ScheduleFactory> */
use HasFactory;

/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Pterodactyl\Exceptions\Http\Server\ServerStateConflictException;
Expand Down Expand Up @@ -104,6 +105,8 @@
*/
class Server extends Model
{
/** @use HasFactory<\Database\Factories\ServerFactory> */
use HasFactory;
use BelongsToThrough;
use Notifiable;

Expand Down
3 changes: 3 additions & 0 deletions app/Models/Subuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* @property int $id
Expand All @@ -18,6 +19,8 @@
*/
class Subuser extends Model
{
/** @use HasFactory<\Database\Factories\SubuserFactory> */
use HasFactory;
use Notifiable;

/**
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Container\Container;
use Znck\Eloquent\Traits\BelongsToThrough;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Pterodactyl\Contracts\Extensions\HashidsInterface;

/**
Expand All @@ -24,6 +25,8 @@
*/
class Task extends Model
{
/** @use HasFactory<\Database\Factories\TaskFactory> */
use HasFactory;
use BelongsToThrough;

/**
Expand Down
3 changes: 3 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Pterodactyl\Traits\Helpers\AvailableLanguages;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
Expand Down Expand Up @@ -89,6 +90,8 @@ class User extends Model implements
use CanResetPassword;
use HasAccessTokens;
use Notifiable;
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory;

public const USER_LEVEL_USER = 0;
public const USER_LEVEL_ADMIN = 1;
Expand Down
3 changes: 3 additions & 0 deletions app/Models/UserSSHKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
* \Pterodactyl\Models\UserSSHKey.
Expand Down Expand Up @@ -39,6 +40,8 @@
*/
class UserSSHKey extends Model
{
/** @use HasFactory<\Database\Factories\UserSSHKeyFactory> */
use HasFactory;
use SoftDeletes;

public const RESOURCE_NAME = 'ssh_key';
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Backups/InitiateBackupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function handle(Server $server, string $name = null, bool $override = fal
if ($previous->count() >= $limit) {
$message = sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period);

throw new TooManyRequestsHttpException(CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), $message);
throw new TooManyRequestsHttpException((int) CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), $message);
}
}

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"friendsofphp/php-cs-fixer": "~3.64.0",
"itsgoingd/clockwork": "~5.2.2",
"larastan/larastan": "~2.9.9",
"laravel/pail": "~1.1.5",
"laravel/sail": "~1.36.0",
"mockery/mockery": "~1.6.12",
"nunomaduro/collision": "~8.5.0",
Expand Down Expand Up @@ -91,7 +92,9 @@
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
"@php artisan key:generate --ansi",
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
]
},
"config": {
Expand Down
Loading

0 comments on commit bd8ac59

Please sign in to comment.