-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppServiceProvider.php
More file actions
66 lines (57 loc) · 1.82 KB
/
Copy pathAppServiceProvider.php
File metadata and controls
66 lines (57 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace App\Providers;
use App\Actions\ViewDataAction;
use App\Checks\FailedJobsCheck;
use App\Checks\FilesystemsDefaultCheck;
use App\Checks\JobsCheck;
use App\Models\Configuration;
use App\Models\News;
use App\Models\Product;
use App\Models\Service;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Spatie\Health\Checks\Checks\CacheCheck;
use Spatie\Health\Checks\Checks\DebugModeCheck;
use Spatie\Health\Checks\Checks\EnvironmentCheck;
use Spatie\Health\Checks\Checks\OptimizedAppCheck;
use Spatie\Health\Facades\Health;
use Spatie\SecurityAdvisoriesHealthCheck\SecurityAdvisoriesCheck;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
//
}
public function boot(): void
{
$this->multilanguage();
Model::unguard();
Model::shouldBeStrict($this->app->isLocal());
Health::checks([
DebugModeCheck::new(),
CacheCheck::new(),
OptimizedAppCheck::new(),
EnvironmentCheck::new()->if(app()->isProduction()),
FilesystemsDefaultCheck::new()->everyFiveMinutes(),
JobsCheck::new()->everyFiveMinutes(),
FailedJobsCheck::new(),
SecurityAdvisoriesCheck::new()->lastDayOfMonth(),
]);
View::share('configuration', $this->getConfiguration());
}
private function multilanguage(): void
{
News::registerLocalizedBinding('news');
Service::registerLocalizedBinding('service');
Product::registerLocalizedBinding('product');
}
private function getConfiguration(): ?Configuration
{
try {
return (new ViewDataAction)->configuration(app()->getLocale());
} catch (\Throwable) {
return null;
}
}
}