75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Support\Facades\Date;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Validation\Rules\Password;
|
|
|
|
use Illuminate\Support\Facades\View;
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
$this->configureDefaults();
|
|
|
|
$settings = Cache::rememberForever('site_settings', function () {
|
|
return [
|
|
'name' => Setting::get('site_name', 'Nama Default'),
|
|
'description' => Setting::get('site_description', 'Deskripsi Default'),
|
|
'keywords' => Setting::get('meta_keywords', 'keyword1, keyword2'),
|
|
'favicon' => Setting::get('site_favicon', ''),
|
|
'logo' => Setting::get('site_logo', ''),
|
|
'accent' => Setting::get('accent_color', 'indigo'),
|
|
'base' => Setting::get('base_color', 'zinc'),
|
|
'registration_open' => Setting::get('registration_open', 'true'),
|
|
];
|
|
});
|
|
|
|
$shades = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900', '950'];
|
|
|
|
// Share satu variabel $site agar rapi
|
|
View::share('site', (object) $settings);
|
|
View::share('themeShades', $shades);
|
|
}
|
|
|
|
/**
|
|
* 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,
|
|
);
|
|
}
|
|
}
|