Add View service provider (prepare to bump slowly)
This commit is contained in:
parent
57fdd70d92
commit
3f32460d60
3 changed files with 40 additions and 7 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
|
@ -26,10 +25,12 @@ class AppServiceProvider extends ServiceProvider
|
|||
return $url->current();
|
||||
});
|
||||
}
|
||||
|
||||
// * LOCAL HTTPS FIX
|
||||
if (!in_array(config('app.env'), ['local', 'testing'])) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
|
||||
// * HA PROXY FIX
|
||||
App::singleton('clientIp', function () {
|
||||
if (config('app.env') == 'local') {
|
||||
|
|
@ -38,6 +39,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
|
||||
}
|
||||
});
|
||||
|
||||
// * LOCAL FORCE eg: for Carbon
|
||||
foreach ([\LC_TIME, \LC_MESSAGES, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY] as $category) {
|
||||
setlocale(
|
||||
|
|
@ -47,9 +49,5 @@ class AppServiceProvider extends ServiceProvider
|
|||
);
|
||||
}
|
||||
Carbon::setLocale(config('app.locale'));
|
||||
if (!app()->runningInConsole()) {
|
||||
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
|
||||
Paginator::useBootstrap();
|
||||
}//end if
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
app/Providers/ViewServiceProvider.php
Normal file
34
app/Providers/ViewServiceProvider.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ViewServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$appInfos = Cache::remember('composer', 360, function () {
|
||||
return json_decode(File::get(\app_path('../composer.json')));
|
||||
});
|
||||
// Share composer.json infos.
|
||||
if (isset($appInfos->name) and isset($appInfos->version)) {
|
||||
View::share('cpsr_name', $appInfos->name);
|
||||
View::share('cpsr_version', $appInfos->version);
|
||||
}
|
||||
|
||||
if (!app()->runningInConsole()) {
|
||||
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ return [
|
|||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
Elasticquent\ElasticquentServiceProvider::class,
|
||||
Elasticquent\ElasticquentServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
|
|
@ -178,7 +178,8 @@ return [
|
|||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\ViewServiceProvider::class
|
||||
|
||||
],
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue