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;
|
2021-04-28 17:04:16 +02:00
|
|
|
use Illuminate\Database\QueryException;
|
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
|
|
|
|
2021-04-28 17:04:16 +02:00
|
|
|
//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;
|
|
|
|
|
}
|
2021-04-20 10:15:22 +02:00
|
|
|
View::share('published_ranges', $ranges);
|
2021-04-08 15:49:20 +02:00
|
|
|
|
2021-05-06 17:18:25 +02:00
|
|
|
//this is useful when setting up the app when tags table doesn't exist yet
|
2021-05-05 17:25:49 +02:00
|
|
|
try {
|
|
|
|
|
// on partage les tags
|
2021-05-07 10:44:23 +02:00
|
|
|
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
2021-05-05 17:25:49 +02:00
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
$tags = null;
|
|
|
|
|
}
|
|
|
|
|
View::share('published_tags', $tags);
|
|
|
|
|
|
2021-05-06 17:18:25 +02:00
|
|
|
//front theme settings
|
|
|
|
|
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
|
|
|
|
View::share('front_settings', $front_settings);
|
|
|
|
|
|
|
|
|
|
|
2021-04-08 15:49:20 +02:00
|
|
|
Blade::directive('fmt_currency', function ($expression) {
|
2021-04-20 10:55:45 +02:00
|
|
|
return "<?php echo sprintf('%s € TTC', number_format($expression, 2, ',', ' ')); ?>";
|
2021-04-08 18:05:17 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Blade::directive('fmt_sellunit', function ($expression) {
|
2021-04-20 10:55:45 +02:00
|
|
|
return "<?php if(!empty($expression)) { echo sprintf('/ %s', $expression); } ?>";
|
2021-04-08 15:49:20 +02:00
|
|
|
});
|
2021-04-19 16:22:24 +02:00
|
|
|
|
|
|
|
|
//default paginator template for back Office
|
|
|
|
|
Paginator::useBootstrap();
|
2020-10-30 17:26:00 +01:00
|
|
|
}
|
|
|
|
|
}
|