2020-10-30 17:26:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2021-03-17 09:28:02 +01:00
|
|
|
use App\Models\Range;
|
2021-05-05 17:25:49 +02:00
|
|
|
use App\Models\Tag;
|
2021-05-06 17:18:25 +02:00
|
|
|
use App\Models\Setting;
|
2021-03-05 11:37:13 +01:00
|
|
|
use Illuminate\Support\Facades\View;
|
2020-10-30 17:26:00 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2021-04-08 15:49:20 +02:00
|
|
|
use Illuminate\Support\Facades\Blade;
|
2021-04-19 16:22:24 +02:00
|
|
|
use Illuminate\Pagination\Paginator;
|
2023-07-10 15:09:06 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2022-09-12 14:26:42 +02:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2022-09-08 13:02:16 +02:00
|
|
|
use Illuminate\Support\Facades\URL;
|
2020-10-30 17:26:00 +01:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function register()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function boot()
|
|
|
|
|
{
|
2022-09-08 13:02:16 +02:00
|
|
|
URL::forceScheme('https');
|
2021-03-23 10:23:05 +01:00
|
|
|
if (config('app.env') !== 'local') {
|
2021-06-07 16:12:13 +02:00
|
|
|
setlocale(LC_TIME, config('app.locale') . "_" . strtoupper(config('app.locale')) . '.utf8');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config('app.env') === 'local') {
|
|
|
|
|
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
|
2021-03-23 10:23:05 +01:00
|
|
|
}
|
2021-03-18 08:40:20 +01:00
|
|
|
|
2022-09-12 14:26:42 +02:00
|
|
|
if (Schema::hasTable('settings')) {
|
|
|
|
|
// The "settings" table exists...
|
|
|
|
|
config([
|
|
|
|
|
'bosettings' => Setting::all()
|
|
|
|
|
->keyBy('key')
|
|
|
|
|
// Key every setting by its name.
|
|
|
|
|
->transform(function ($setting) {
|
|
|
|
|
return $setting->value;
|
|
|
|
|
// Return only the value.
|
|
|
|
|
})
|
|
|
|
|
->toArray()
|
|
|
|
|
// Make it an array.
|
|
|
|
|
]);
|
2022-09-08 13:02:16 +02:00
|
|
|
|
2022-09-12 14:26:42 +02:00
|
|
|
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
|
|
|
|
// Front theme settings.
|
|
|
|
|
View::share('front_settings', $front_settings);
|
|
|
|
|
}
|
2021-04-08 15:49:20 +02:00
|
|
|
|
2022-09-12 14:26:42 +02:00
|
|
|
if (Schema::hasTable('ranges')) {
|
|
|
|
|
// On partage les ranges (gammes produit).
|
|
|
|
|
$ranges = Range::where('status', '1')->get();
|
|
|
|
|
View::share('published_ranges', $ranges);
|
|
|
|
|
}
|
2021-05-05 17:25:49 +02:00
|
|
|
|
2022-09-12 14:26:42 +02:00
|
|
|
if (Schema::hasTable('tags')) {
|
|
|
|
|
// On partage les tags.
|
|
|
|
|
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
|
|
|
|
View::share('published_tags', $tags);
|
|
|
|
|
}
|
2021-05-06 17:18:25 +02:00
|
|
|
|
2026-02-02 15:47:55 +01:00
|
|
|
// Use blade directives helper to prevent blade files from being cached.
|
2023-07-10 15:09:06 +00:00
|
|
|
Blade::directive('fmt_currency_without_auth', function ($expression) {
|
2026-02-02 15:47:55 +01:00
|
|
|
return "<?php echo \App\Helpers\BladeDirectivesHelper::formatPriceValue($expression); ?>";
|
2021-04-08 18:05:17 +02:00
|
|
|
});
|
2023-07-10 15:09:06 +00:00
|
|
|
Blade::directive('fmt_currency', function ($expression) {
|
2026-02-02 15:47:55 +01:00
|
|
|
return "<?php echo \App\Helpers\BladeDirectivesHelper::formatCurrency($expression); ?>";
|
2023-07-10 15:09:06 +00:00
|
|
|
});
|
2022-10-14 14:52:56 +02:00
|
|
|
Blade::directive('fmt_currency_without_ttc', function ($expression) {
|
2026-02-02 15:47:55 +01:00
|
|
|
return "<?php echo \App\Helpers\BladeDirectivesHelper::formatCurrency($expression); ?>";
|
2022-10-14 14:52:56 +02:00
|
|
|
});
|
2021-04-08 18:05:17 +02:00
|
|
|
Blade::directive('fmt_sellunit', function ($expression) {
|
2026-02-02 15:47:55 +01:00
|
|
|
return "<?php echo \App\Helpers\BladeDirectivesHelper::formatSellUnit($expression); ?>";
|
2021-04-08 15:49:20 +02:00
|
|
|
});
|
2022-09-08 11:29:39 +02:00
|
|
|
Blade::directive('excerpt_product_title', function ($expression) {
|
2026-02-02 15:47:55 +01:00
|
|
|
return "<?php echo \App\Helpers\BladeDirectivesHelper::excerptTitle($expression); ?>";
|
2021-05-26 17:25:30 +02:00
|
|
|
});
|
|
|
|
|
|
2022-09-08 13:02:16 +02:00
|
|
|
// Default paginator template for back Office.
|
2021-04-19 16:22:24 +02:00
|
|
|
Paginator::useBootstrap();
|
2020-10-30 17:26:00 +01:00
|
|
|
}
|
|
|
|
|
}
|