misc_pterodactyl-panel/app/Providers/AppServiceProvider.php

59 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Providers;
use Laravel\Sanctum\Sanctum;
2021-08-07 23:10:24 +00:00
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser;
use Illuminate\Support\Facades\URL;
2017-09-25 03:34:30 +00:00
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Pterodactyl\Observers\UserObserver;
use Pterodactyl\Observers\ServerObserver;
use Pterodactyl\Observers\SubuserObserver;
use Pterodactyl\Models\PersonalAccessToken;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot()
{
2017-09-25 03:34:30 +00:00
Schema::defaultStringLength(191);
User::observe(UserObserver::class);
Server::observe(ServerObserver::class);
Subuser::observe(SubuserObserver::class);
2021-08-07 23:10:24 +00:00
/*
* @see https://laravel.com/docs/8.x/sanctum#overriding-default-models
*/
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
// If the APP_URL value is set with https:// make sure we force it here. Theoretically
// this should just work with the proxy logic, but there are a lot of cases where it
// doesn't, and it triggers a lot of support requests, so lets just head it off here.
//
// @see https://github.com/pterodactyl/panel/issues/3623
if (Str::startsWith(config('app.url') ?? '', 'https://')) {
URL::forceScheme('https');
}
}
2017-12-30 22:33:00 +00:00
/**
* Register application service providers.
*/
public function register()
{
Sanctum::ignoreMigrations();
2017-12-30 22:33:00 +00:00
// Only load the settings service provider if the environment
// is configured to allow it.
2021-08-07 23:10:24 +00:00
if (!config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') {
2017-12-30 22:33:00 +00:00
$this->app->register(SettingsServiceProvider::class);
}
}
}