76 lines
2.2 KiB
PHP
76 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Range;
|
|
use App\Models\Tag;
|
|
use App\Models\Setting;
|
|
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);
|
|
|
|
//this is useful when setting up the app when tags table doesn't exist yet
|
|
try {
|
|
// on partage les tags
|
|
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
|
|
} catch (QueryException $e) {
|
|
$tags = null;
|
|
}
|
|
View::share('published_tags', $tags);
|
|
|
|
//front theme settings
|
|
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
|
|
View::share('front_settings', $front_settings);
|
|
|
|
|
|
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); } ?>";
|
|
});
|
|
|
|
Blade::directive('excerpt_product_title', function($expression) {
|
|
$limit = config('theme.max_product_title_length');
|
|
return "<?php echo Illuminate\Support\Str::limit($expression,$limit) ?>";
|
|
});
|
|
|
|
//default paginator template for back Office
|
|
Paginator::useBootstrap();
|
|
}
|
|
}
|