Skip to content

Commit 6554f58

Browse files
Add safer defaults to AppServiceProvider (#213)
1 parent 49d0139 commit 6554f58

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

app/Providers/AppServiceProvider.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
namespace App\Providers;
44

5+
use Carbon\CarbonImmutable;
6+
use Illuminate\Support\Facades\Date;
7+
use Illuminate\Support\Facades\DB;
58
use Illuminate\Support\ServiceProvider;
9+
use Illuminate\Validation\Rules\Password;
610

711
class AppServiceProvider extends ServiceProvider
812
{
@@ -19,6 +23,25 @@ public function register(): void
1923
*/
2024
public function boot(): void
2125
{
22-
//
26+
$this->configureDefaults();
27+
}
28+
29+
protected function configureDefaults(): void
30+
{
31+
Date::use(CarbonImmutable::class);
32+
33+
DB::prohibitDestructiveCommands(
34+
app()->isProduction(),
35+
);
36+
37+
Password::defaults(fn (): ?Password => app()->isProduction()
38+
? Password::min(12)
39+
->mixedCase()
40+
->letters()
41+
->numbers()
42+
->symbols()
43+
->uncompromised()
44+
: null
45+
);
2346
}
2447
}

0 commit comments

Comments
 (0)