55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Range;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Pagination\Paginator;
|
|
use Illuminate\Database\QueryException;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
if (config('app.env') !== 'local') {
|
|
\URL::forceScheme('https');
|
|
}
|
|
|
|
//this is useful when setting up the app whene ranges table doesn't exist yet
|
|
try {
|
|
// on partage les ranges (gammes produit)
|
|
$ranges = Range::where('status', '1')->get();
|
|
} catch (QueryException $e) {
|
|
$ranges = null;
|
|
}
|
|
View::share('published_ranges', $ranges);
|
|
|
|
Blade::directive('fmt_currency', function ($expression) {
|
|
return "<?php echo sprintf('%s € TTC', number_format($expression, 2, ',', ' ')); ?>";
|
|
});
|
|
|
|
Blade::directive('fmt_sellunit', function ($expression) {
|
|
return "<?php if(!empty($expression)) { echo sprintf('/ %s', $expression); } ?>";
|
|
});
|
|
|
|
//default paginator template for back Office
|
|
Paginator::useBootstrap();
|
|
}
|
|
}
|