|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Rules\ValidateGoogleUrl; |
|
6
|
|
|
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider; |
|
7
|
|
|
use Carbon\Carbon; |
|
8
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
9
|
|
|
use Illuminate\Support\Facades\DB; |
|
10
|
|
|
use Illuminate\Support\Facades\Schema; |
|
11
|
|
|
use Illuminate\Support\Facades\Validator; |
|
12
|
|
|
use Illuminate\Support\ServiceProvider; |
|
13
|
|
|
use Laravel\Dusk\DuskServiceProvider; |
|
14
|
|
|
use Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider; |
|
15
|
|
|
use Recca0120\LaravelTracy\LaravelTracyServiceProvider; |
|
16
|
|
|
use STS\Filesystem\VfsFilesystemServiceProvider; |
|
17
|
|
|
use Way\Generators\GeneratorsServiceProvider; |
|
18
|
|
|
|
|
19
|
|
|
class AppServiceProvider extends ServiceProvider |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Bootstrap any application services. |
|
23
|
|
|
* |
|
24
|
|
|
* @return void |
|
25
|
|
|
*/ |
|
26
|
|
|
public function boot() |
|
27
|
|
|
{ |
|
28
|
|
|
/* |
|
29
|
|
|
* Application locale defaults for various components |
|
30
|
|
|
* |
|
31
|
|
|
* These will be overridden by LocaleMiddleware if the session local is set |
|
32
|
|
|
*/ |
|
33
|
|
|
|
|
34
|
|
|
/* |
|
35
|
|
|
* setLocale for php. Enables ->formatLocalized() with localized values for dates |
|
36
|
|
|
*/ |
|
37
|
|
|
setlocale(LC_TIME, config('app.locale_php')); |
|
38
|
|
|
|
|
39
|
|
|
/* |
|
40
|
|
|
* setLocale to use Carbon source locales. Enables diffForHumans() localized |
|
41
|
|
|
*/ |
|
42
|
|
|
Carbon::setLocale(config('app.locale')); |
|
43
|
|
|
|
|
44
|
|
|
/* |
|
45
|
|
|
* Set the session variable for whether or not the app is using RTL support |
|
46
|
|
|
* For use in the blade directive in BladeServiceProvider |
|
47
|
|
|
*/ |
|
48
|
|
|
if (config('locale.languages')[config('app.locale')][2]) { |
|
49
|
|
|
session(['lang-rtl' => true]); |
|
50
|
|
|
} else { |
|
51
|
|
|
session()->forget('lang-rtl'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
// Force SSL in production |
|
55
|
|
|
if ($this->app->environment() === 'production') { |
|
|
|
|
|
|
56
|
|
|
//URL::forceScheme('https'); |
|
|
|
|
|
|
57
|
|
|
} else { |
|
58
|
|
|
DB::enableQueryLog(); |
|
59
|
|
|
// DB::listen(function ($query) { |
|
|
|
|
|
|
60
|
|
|
// var_dump([ $query->sql, $query->bindings, $query->time ]); |
|
|
|
|
|
|
61
|
|
|
// }); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
// Set the default string length for Laravel5.4 |
|
65
|
|
|
// https://laravel-news.com/laravel-5-4-key-too-long-error |
|
66
|
|
|
Schema::defaultStringLength(191); |
|
67
|
|
|
|
|
68
|
|
|
if (app()->resolved('bugsnag')) { |
|
69
|
|
|
$bugsnag = app('bugsnag'); |
|
70
|
|
|
$bugsnag->setReleaseStage(env('BUGSNAG_RELEASE_STAGE', '')); |
|
71
|
|
|
$bugsnag->setErrorReportingLevel(E_ALL & ~E_NOTICE); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
//register validation rules |
|
75
|
|
|
Validator::extend('googleUrl', ValidateGoogleUrl::class . '@validateSheet'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Register any application services. |
|
80
|
|
|
* |
|
81
|
|
|
* @return void |
|
82
|
|
|
*/ |
|
83
|
|
|
public function register() |
|
84
|
|
|
{ |
|
85
|
|
|
/* |
|
86
|
|
|
* Sets third party service providers that are only needed on local/testing environments |
|
87
|
|
|
*/ |
|
88
|
|
|
$environment = $this->app->environment(); |
|
89
|
|
|
if ($environment !== 'production') { |
|
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Loader for registering facades. |
|
92
|
|
|
*/ |
|
93
|
|
|
$loader = AliasLoader::getInstance(); |
|
|
|
|
|
|
94
|
|
|
/* |
|
95
|
|
|
* Load third party local providers and facades |
|
96
|
|
|
*/ |
|
97
|
|
|
//$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class); |
|
|
|
|
|
|
98
|
|
|
//$loader->alias('Debugbar', Facade::class); |
|
|
|
|
|
|
99
|
|
|
$this->app->register(IdeHelperServiceProvider::class); |
|
100
|
|
|
$this->app->register(TestFactoryHelperServiceProvider::class); |
|
101
|
|
|
$this->app->register(GeneratorsServiceProvider::class); |
|
102
|
|
|
// $this->app->register(MigrationsGeneratorServiceProvider::class); |
|
|
|
|
|
|
103
|
|
|
// $this->app->register(IseedServiceProvider::class); |
|
|
|
|
|
|
104
|
|
|
$this->app->register(DuskServiceProvider::class); |
|
105
|
|
|
// $this->app->register(DbSnapshotsServiceProvider::class); |
|
|
|
|
|
|
106
|
|
|
$this->app->register(\Backpack\Generators\GeneratorsServiceProvider::class); |
|
107
|
|
|
if (class_exists(VfsFilesystemServiceProvider::class)) { |
|
108
|
|
|
$this->app->register(VfsFilesystemServiceProvider::class); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
if (! \in_array($environment, ['production', 'testing'], true)) { |
|
112
|
|
|
$this->app->register(LaravelTracyServiceProvider::class); |
|
113
|
|
|
} |
|
114
|
|
|
$this->app->bind('path.public', |
|
115
|
|
|
function () { |
|
116
|
|
|
return base_path() . '/web'; |
|
117
|
|
|
}); |
|
118
|
|
|
$this->app->alias('bugsnag.multi', \Illuminate\Contracts\Logging\Log::class); |
|
119
|
|
|
$this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|