misc_pterodactyl-panel/app/Providers/AppServiceProvider.php

60 lines
1.9 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Providers;
use Pterodactyl\Models;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\URL;
use Illuminate\Pagination\Paginator;
2017-09-25 03:34:30 +00:00
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Relations\Relation;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot()
{
2017-09-25 03:34:30 +00:00
Schema::defaultStringLength(191);
Paginator::useBootstrap();
// 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');
}
Relation::enforceMorphMap([
'allocation' => Models\Allocation::class,
'api_key' => Models\ApiKey::class,
'backup' => Models\Backup::class,
'database' => Models\Database::class,
'egg' => Models\Egg::class,
'egg_variable' => Models\EggVariable::class,
'schedule' => Models\Schedule::class,
'server' => Models\Server::class,
'ssh_key' => Models\UserSSHKey::class,
'task' => Models\Task::class,
'user' => Models\User::class,
]);
}
2017-12-30 22:33:00 +00:00
/**
* Register application service providers.
*/
public function register()
{
// Only load the settings service provider if the environment
// is configured to allow it.
2021-01-23 20:33:34 +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);
}
}
}