Created
December 3, 2024 09:06
-
-
Save rokde/e517a9f6ff9ed5815c9e927f54d2f3d1 to your computer and use it in GitHub Desktop.
Laravel AppServiceProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Providers; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\Facades\DB; | |
use Illuminate\Support\Facades\URL; | |
use Illuminate\Support\Facades\Vite; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
*/ | |
public function boot(): void | |
{ | |
$this->configureCommands(); | |
$this->configureModels(); | |
$this->configureUrl(); | |
$this->configureVite(); | |
} | |
/** | |
* Configure the application's commands. | |
*/ | |
private function configureCommands(): void | |
{ | |
DB::prohibitDestructiveCommands( | |
$this->app->isProduction(), | |
); | |
} | |
/** | |
* Configure the application's models. | |
*/ | |
private function configureModels(): void | |
{ | |
Model::shouldBeStrict(); | |
Model::unguard(); | |
} | |
/** | |
* Configure the application's URL. | |
*/ | |
private function configureUrl(): void | |
{ | |
URL::forceScheme('https'); | |
} | |
/** | |
* Configure the application's Vite. | |
*/ | |
private function configureVite(): void | |
{ | |
Vite::usePrefetchStrategy('aggressive'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configure your laravel app in a nice manner.