ldc-cocotte/app/Providers/AppServiceProvider.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2020-10-30 17:26:00 +01:00
<?php
namespace App\Providers;
use App\Models\Range;
use Illuminate\Support\Facades\View;
2020-10-30 17:26:00 +01:00
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
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()
{
2021-03-23 10:23:05 +01:00
if (config('app.env') !== 'local') {
\URL::forceScheme('https');
}
2021-03-18 08:40:20 +01:00
// on partage les ranges (gammes produit)
$ranges = Range::all();
View::share('ranges', $ranges);
Blade::directive('fmt_currency', function ($expression) {
2021-04-08 18:05:17 +02:00
return "<?php echo sprintf('%s €', number_format($expression, 2, ',', ' ')); ?>";
});
Blade::directive('fmt_sellunit', function ($expression) {
if (!empty($$expression)) {
return "<?php echo sprintf('/ %s', $expression); ?>";
}
});
2020-10-30 17:26:00 +01:00
}
}