proper way for cinjecting view shares taking fresh migration into account
This commit is contained in:
parent
2534188942
commit
64868010d4
1 changed files with 28 additions and 20 deletions
|
|
@ -9,6 +9,7 @@ use Illuminate\Support\Facades\View;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Blade;
|
use Illuminate\Support\Facades\Blade;
|
||||||
use Illuminate\Pagination\Paginator;
|
use Illuminate\Pagination\Paginator;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
|
@ -38,29 +39,36 @@ class AppServiceProvider extends ServiceProvider
|
||||||
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
|
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
config([
|
if (Schema::hasTable('settings')) {
|
||||||
'bosettings' => Setting::all()
|
// The "settings" table exists...
|
||||||
->keyBy('key')
|
config([
|
||||||
// Key every setting by its name.
|
'bosettings' => Setting::all()
|
||||||
->transform(function ($setting) {
|
->keyBy('key')
|
||||||
return $setting->value;
|
// Key every setting by its name.
|
||||||
// Return only the value.
|
->transform(function ($setting) {
|
||||||
})
|
return $setting->value;
|
||||||
->toArray()
|
// Return only the value.
|
||||||
// Make it an array.
|
})
|
||||||
]);
|
->toArray()
|
||||||
|
// Make it an array.
|
||||||
|
]);
|
||||||
|
|
||||||
// On partage les ranges (gammes produit).
|
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
||||||
$ranges = Range::where('status', '1')->get();
|
// Front theme settings.
|
||||||
View::share('published_ranges', $ranges);
|
View::share('front_settings', $front_settings);
|
||||||
|
}
|
||||||
|
|
||||||
// On partage les tags.
|
if (Schema::hasTable('ranges')) {
|
||||||
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
// On partage les ranges (gammes produit).
|
||||||
View::share('published_tags', $tags);
|
$ranges = Range::where('status', '1')->get();
|
||||||
|
View::share('published_ranges', $ranges);
|
||||||
|
}
|
||||||
|
|
||||||
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
if (Schema::hasTable('tags')) {
|
||||||
// Front theme settings.
|
// On partage les tags.
|
||||||
View::share('front_settings', $front_settings);
|
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
||||||
|
View::share('published_tags', $tags);
|
||||||
|
}
|
||||||
|
|
||||||
Blade::directive('fmt_currency', function ($expression) {
|
Blade::directive('fmt_currency', function ($expression) {
|
||||||
return "<?php
|
return "<?php
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue