You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.0 KiB
59 lines
2.0 KiB
<?php
|
|
|
|
namespace App\Domains\System\Providers;
|
|
|
|
use App\Domains\Identity\Events\Governance\UserWasPurged;
|
|
use App\Domains\System\Enums\SystemSettingKey;
|
|
use App\Domains\System\Events\ExportCompleted;
|
|
use App\Domains\System\Events\ImportCompleted;
|
|
use App\Domains\System\Listeners\Excel\SendExportReportEmail;
|
|
use App\Domains\System\Listeners\Excel\SendImportReportEmail;
|
|
use App\Domains\System\Listeners\Files\RemoveUserFiles;
|
|
use App\Domains\System\Queries\GetSystemSettings;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use OwenIt\Auditing\Models\Audit;
|
|
use View;
|
|
|
|
class SystemServiceProvider extends ServiceProvider
|
|
{
|
|
public static array $listen = [
|
|
ExportCompleted::class => [
|
|
SendExportReportEmail::class,
|
|
],
|
|
ImportCompleted::class => [
|
|
SendImportReportEmail::class,
|
|
],
|
|
UserWasPurged::class => [
|
|
RemoveUserFiles::class,
|
|
]
|
|
];
|
|
|
|
public function register(): void
|
|
{
|
|
// Tell Laravel: "Whenever someone asks for GetSystemSettings,
|
|
// give them the exact same object instance for the entire request."
|
|
$this->app->singleton(GetSystemSettings::class, function ($app) {
|
|
return new GetSystemSettings;
|
|
});
|
|
}
|
|
|
|
/** @noinspection PhpInconsistentReturnPointsInspection */
|
|
public function boot(GetSystemSettings $getSystemSettings): void
|
|
{
|
|
View::composer(['components.layouts.*'], function ($view) use ($getSystemSettings) {
|
|
$view->with('logo', $getSystemSettings->get(SystemSettingKey::WEB_LOGO));
|
|
$view->with('favicon', $getSystemSettings->get(SystemSettingKey::WEB_FAVICON));
|
|
});
|
|
|
|
Audit::creating(function (Audit $model) {
|
|
if (empty($model->old_values) && empty($model->new_values)) {
|
|
return false;
|
|
}
|
|
});
|
|
|
|
Carbon::macro('toUserTz', fn () => $this->copy()
|
|
->tz(config('app.display_timezone', 'UTC')));
|
|
}
|
|
}
|
|
|