48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Setting;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if (config('database.default') === 'sqlite') {
|
|
DB::statement('PRAGMA journal_mode=WAL');
|
|
DB::statement('PRAGMA synchronous=NORMAL');
|
|
DB::statement('PRAGMA busy_timeout=5000');
|
|
DB::statement('PRAGMA foreign_keys=ON');
|
|
}
|
|
|
|
try {
|
|
$companyName = Setting::query()->where('key', 'company_name')->value('value');
|
|
$timezone = Setting::query()->where('key', 'timezone')->value('value');
|
|
|
|
if ($companyName) {
|
|
config(['app.name' => $companyName]);
|
|
}
|
|
|
|
if ($timezone) {
|
|
config(['app.timezone' => $timezone]);
|
|
date_default_timezone_set($timezone);
|
|
}
|
|
} catch (\Throwable) {
|
|
// During initial migration the settings table can be unavailable.
|
|
}
|
|
}
|
|
}
|