70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Auth\BcryptPasswordHasher;
|
|
use App\Auth\Clock;
|
|
use App\Auth\EloquentSessionRepository;
|
|
use App\Auth\PasswordHasher;
|
|
use App\Auth\RandomTokenGenerator;
|
|
use App\Auth\SessionRepository;
|
|
use App\Auth\SystemClock;
|
|
use App\Auth\TokenGenerator;
|
|
use App\User\EloquentUserRepository;
|
|
use App\User\UserRepository;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Support\Facades\Date;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
$this->app->bind(
|
|
UserRepository::class,
|
|
EloquentUserRepository::class,
|
|
);
|
|
$this->app->bind(
|
|
SessionRepository::class,
|
|
EloquentSessionRepository::class,
|
|
);
|
|
$this->app->bind(PasswordHasher::class, BcryptPasswordHasher::class);
|
|
$this->app->bind(TokenGenerator::class, RandomTokenGenerator::class);
|
|
$this->app->bind(Clock::class, SystemClock::class);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->configureDefaults();
|
|
}
|
|
|
|
/**
|
|
* Configure default behaviors for production-ready applications.
|
|
*/
|
|
protected function configureDefaults(): void
|
|
{
|
|
Date::use(CarbonImmutable::class);
|
|
|
|
DB::prohibitDestructiveCommands(
|
|
app()->isProduction(),
|
|
);
|
|
|
|
Password::defaults(fn (): ?Password => app()->isProduction()
|
|
? Password::min(12)
|
|
->mixedCase()
|
|
->letters()
|
|
->numbers()
|
|
->symbols()
|
|
->uncompromised()
|
|
: null,
|
|
);
|
|
}
|
|
}
|