34 lines
797 B
PHP
34 lines
797 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Illuminate\Support\Facades\URL;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// Force HTTPS when behind a reverse proxy
|
|
if (str_starts_with(config('app.url'), 'https://')) {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
// Auto-generate APP_KEY if missing
|
|
if (empty(config('app.key'))) {
|
|
Artisan::call('key:generate', ['--force' => true]);
|
|
}
|
|
|
|
Gate::before(function ($user, $ability) {
|
|
return $user->hasRole('amministratore') ? true : null;
|
|
});
|
|
}
|
|
}
|