AppServiceProvider.php
2.64 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace App\Providers;
use Carbon\Carbon;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
/*
* Application locale defaults for various components
*
* These will be overridden by LocaleMiddleware if the session local is set
*/
/*
* setLocale for php. Enables ->formatLocalized() with localized values for dates
*/
setlocale(LC_TIME, config('app.locale_php'));
/*
* setLocale to use Carbon source locales. Enables diffForHumans() localized
*/
Carbon::setLocale(config('app.locale'));
/*
* Set the session variable for whether or not the app is using RTL support
* For use in the blade directive in BladeServiceProvider
*/
if (config('locale.languages')[config('app.locale')][2]) {
session(['lang-rtl' => true]);
} else {
session()->forget('lang-rtl');
}
// Force SSL in production
if ($this->app->environment() == 'production') {
//URL::forceScheme('https');
}
// Set the default string length for Laravel5.4
// https://laravel-news.com/laravel-5-4-key-too-long-error
Schema::defaultStringLength(191);
Validator::extend('sms_verify', 'App\Modules\Validators\SmsValidator@validate');
Validator::extend('ota_version_format', 'App\Modules\Validators\OtaVersionFormatValidator@validate');
Validator::extend('ota_version_check', 'App\Modules\Validators\OtaVersionCheckValidator@validate');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
/*
* Sets third party service providers that are only needed on local/testing environments
*/
if ($this->app->environment() != 'production') {
/**
* Loader for registering facades.
*/
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
/*
* Load third party local providers
*/
// $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
/*
* Load third party local aliases
*/
// $loader->alias('Debugbar', \Barryvdh\Debugbar\Facade::class);
}
}
}