Merge branch 'trunk'

This commit is contained in:
Noah Lancien 2026-03-26 16:16:29 +01:00
commit 5d2d58cd7a
30 changed files with 854 additions and 247 deletions

View file

@ -43,6 +43,8 @@ SENTRY_LARAVEL_DSN=
# Matomo
MATOMO_SITE_ID=
## ADMIN SECURE
LDC_WEB_API_KEY=
LDC_WEB_CIDR_MANUAL_ALLOWED_LIST=
# UWIL ADMIN SECURE
# - LIST SEPARATED WITH ',' (Required)
UWIL_ADMIN_SECURE_CIDR_LIST=""
# - LIST SEPARATED WITH ',' (Optional)
UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST=""

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\ProductRequest;
use App\Http\Requests\Bo\UpdateProductOrderRequest;
use App\Models\OldSlug;
use App\Models\FoodProduct;
use App\Models\ToolProduct;
@ -18,6 +19,7 @@ use App\Traits\Controllers\ChangesModelOrder;
use App\Traits\Controllers\UpdateModelStatus;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\File;
@ -867,4 +869,35 @@ class ProductsController extends Controller
$products = Product::where('star', 1)->paginate(10);
return view('bo.products.starred', compact('products'));
}
/**
* Update product order.
*
* @param UpdateProductOrderRequest $request
* @param Product $product
* @return void
*/
public function changeSelectedOrder(UpdateProductOrderRequest $request, Product $product)
{
// Laravel 8 style ... validated() never returns a string.
$validated = $request->validated();
$newOrder = $validated['order'];
return DB::transaction(function () use ($product, $newOrder) {
// Update all products who will be moved with this order update.
// Includes soft deleted to avoid problems if we restore them.
$request = Product::withTrashed()
->where('id', '!=', $product->id)
->whereBetween('order', [min($product->order, $newOrder), max($product->order, $newOrder)]);
$product->order < $newOrder ? $request->decrement('order', 1) : $request->increment('order', 1);
// Update the product.
$product->order = $newOrder;
if (!$product->saveOrFail()) {
return back()->with('error', trans('crud.messages.order_not_changed'));
};
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
});
}
}

View file

@ -49,17 +49,19 @@ class PromotionsController extends Controller
'product_id' => 'required',
]);
$productIds = explode(",", $request->product_id);
$discType = $request->discount_type_id;
$value = $request->discount_value;
$date_start = $request->date_start_date . " " . $request->date_start_time;
$date_end = $request->date_end_date . " " . $request->date_end_time;
$productIds = explode(",", $request->product_id);
$discType = $request->discount_type_id;
$value = $request->discount_value;
$isOldPriceDisplayed = $request->boolean('is_old_price_displayed');
$date_start = $request->date_start_date . " " . $request->date_start_time;
$date_end = $request->date_end_date . " " . $request->date_end_time;
$promotion = new Promotion();
$promotion->discount_type_id = $discType;
$promotion->discount_value = $value;
$promotion->date_start = $date_start;
$promotion->date_end = $date_end;
$promotion = new Promotion();
$promotion->discount_type_id = $discType;
$promotion->discount_value = $value;
$promotion->is_old_price_displayed = $isOldPriceDisplayed;
$promotion->date_start = $date_start;
$promotion->date_end = $date_end;
$promotion->save();
// Prise en charge de la liaison avec les produits.
@ -101,16 +103,18 @@ class PromotionsController extends Controller
'product_id' => 'required',
]);
$productIds = explode(",", $request->product_id);
$discType = $request->discount_type_id;
$value = $request->discount_value;
$date_start = $request->date_start_date . " " . $request->date_start_time;
$date_end = $request->date_end_date . " " . $request->date_end_time;
$productIds = explode(",", $request->product_id);
$discType = $request->discount_type_id;
$value = $request->discount_value;
$isOldPriceDisplayed = $request->boolean('is_old_price_displayed');
$date_start = $request->date_start_date . " " . $request->date_start_time;
$date_end = $request->date_end_date . " " . $request->date_end_time;
$promotion->discount_type_id = $discType;
$promotion->discount_value = $value;
$promotion->date_start = $date_start;
$promotion->date_end = $date_end;
$promotion->discount_type_id = $discType;
$promotion->discount_value = $value;
$promotion->is_old_price_displayed = $isOldPriceDisplayed;
$promotion->date_start = $date_start;
$promotion->date_end = $date_end;
$promotion->save();
// Prise en charge de la liaison avec les produits.

View file

@ -88,12 +88,18 @@ class ProductsController extends Controller
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Product> */
$products = $productsQuery->orderBy('order', 'ASC')->paginate(6);
$brands = \collect(\App\Enums\ProductBrand::toArray())->filter(
function (\App\Enums\ProductBrand $case) {
return Product::query()->pluck('brand')->contains($case->value);
}
)->values();
if ($request->ajax()) {
return \response()->json([ProductResource::collection($products), $products->total()]);
} else {
$ranges = Range::all();
$tags = Tag::where('status', true)->get();
return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen'));
return view('ranges', compact('products', 'ranges', 'tags', 'sessionFilter', 'filtersMenuIsOpen', 'brands'));
}
}

View file

@ -63,5 +63,6 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'is-admin' => \App\Http\Middleware\IsAdmin::class,
'is-super-admin' => \App\Http\Middleware\IsSuperAdmin::class,
'admin-secure' => \App\Http\Middleware\AdminSecureMiddleware::class,
];
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Http\Middleware;
use App\Lib\AdminSecure;
use Closure;
use Dxw\CIDR\IP;
use Illuminate\Http\Request;
class AdminSecureMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (config('app.env') === 'local') {
return $next($request);
}
$client_ip = AdminSecure::fetchClientIp();
$ip_is_allowed = \collect(AdminSecure::getOptions()->getCidrList())
->reduce(function ($initial, $ip_range) use ($client_ip) {
return $initial || IP::contains(
$ip_range,
$client_ip
)->unwrap();
});
$ip_is_allowed_by_config = \collect(AdminSecure::getOptions()->getCidrAllowedList())
->reduce(function ($initial, $ip_range) use ($client_ip) {
return $initial || IP::contains(
$ip_range,
$client_ip
)->unwrap();
});
if ($ip_is_allowed or $ip_is_allowed_by_config or AdminSecure::ipIsPrivate($client_ip)) {
return $next($request);
}
abort(403, \trans('Denied IP'));
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace App\Http\Requests\Bo;
use App\Models\Product;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProductOrderRequest extends FormRequest
{
private $product;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->product = $this->route('product');
$max = Product::query()->max('order');
$this->merge([
'order' => min($this->input('order'), $max)
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'order' => [
'required',
'integer',
'min:1',
function ($attribute, $value, $fail) {
if ($this->product && intval($value) === $this->product->order) {
$fail("La valeur de {$attribute} doit être différente de la valeur actuelle.");
}
},
],
];
}
}

131
app/Lib/AdminSecure.php Normal file
View file

@ -0,0 +1,131 @@
<?php
namespace App\Lib;
use App\Lib\Options;
use Dxw\CIDR\IPAddress;
use Dxw\CIDR\IPv4Address;
use Dxw\CIDR\IPv4Range;
use Dxw\CIDR\IPv6Address;
use Dxw\CIDR\IPv6Range;
abstract class AdminSecure
{
/**
* Private ipV4 CIDR list
*
* @var array
*/
private static $private_ip_v4_cidr_list = [
'10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'
];
/**
* Private ipV4 CIDR loopback
*
* @var string
*/
private static $private_ip_v4_loopback_cidr = '127.0.0.0/8';
/**
* Private ipV6 CIDR list
*
* @var array
*/
private static $private_ip_v6_cidr_list = [
'fd00::/8'
];
/**
* Private ipV6 CIDR loopback
*
* @var string
*/
private static $private_ip_v6_loopback_cidr = '::1/128';
/**
* Private options
*
* @var \Uwil\AdminSecure\Laravel\Options|null
*/
private static $options = null;
/**
* Check if ip is private
*
* @param \Dxw\CIDR\IPv4Address|\Dxw\CIDR\IPv6Address $ip_address
* @return boolean
*/
public static function ipIsPrivate($ip_address): bool
{
return \get_class($ip_address) === IPv4Address::class ?
self::ipV4IsPrivate($ip_address) : self::ipV6IsPrivate($ip_address);
}
/**
* Fetch client IP
*
* @return \Dxw\CIDR\IPv4Address|\Dxw\CIDR\IPv6Address
* @throws \Uwil\AdminSecure\Laravel\Exceptions\AdminSecureException If the ip is invalid.
*/
public static function fetchClientIp()
{
// ! REVERSE PROXY HACK.
$ip = request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
$ip = IPAddress::Make($ip);
if ($ip->isErr()) {
throw new \Exception(\trans('Client IP not valid ') . $ip->getErr());
}
return $ip->unwrap();
}
/**
* Check if ipV4 is private
*
* @param \Dxw\CIDR\IPv4Address $ipv4_address
* @return boolean
*/
private static function ipV4IsPrivate(IPv4Address $ipv4_address): bool
{
return \collect(self::$private_ip_v4_cidr_list)
->concat([self::$private_ip_v4_loopback_cidr])
->map(function (string $ipv4_cidr) {
return IPv4Range::Make($ipv4_cidr)->unwrap();
})
->reduce(function ($initial, IPv4Range $ipv4_range) use ($ipv4_address) {
return $initial || $ipv4_range->containsAddress($ipv4_address);
});
}
/**
* Check if ipV6 is private
*
* @param \Dxw\CIDR\IPv6Address $ipv6_address
* @return boolean
*/
private static function ipV6IsPrivate(IPv6Address $ipv6_address): bool
{
return \collect(self::$private_ip_v6_cidr_list)
->concat([self::$private_ip_v6_loopback_cidr])
->map(function (string $ipv6_cidr) {
return IPv6Range::Make($ipv6_cidr)->unwrap();
})
->reduce(function ($initial, IPv6Range $ipv6_range) {
return $initial || $ipv6_range->containsAddress($ipv6_address);
});
}
/**
* Get Admin secure options
*
* @return \App\Lib\Options
*/
public static function getOptions(): Options
{
if (!self::$options) {
self::$options = new Options(\config('admin-secure'));
}
return self::$options;
}
}

159
app/Lib/Options.php Normal file
View file

@ -0,0 +1,159 @@
<?php
declare(strict_types=1);
namespace App\Lib;
use Dxw\CIDR\IPv4Range;
use Dxw\CIDR\IPv6Range;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Configuration
*/
final class Options
{
/**
* @var array<string, mixed> The configuration options
*/
private $options;
/**
* @var \Symfony\Component\OptionsResolver\OptionsResolver The options resolver
*/
private $resolver;
/**
* The cache key where to store config cidr list.
*
* @var string
*/
private static $cache_config_key = 'uwil_ip_cidr_config_list';
/**
* Class constructor.
*
* @param array<string, mixed> $options The configuration options.
*/
public function __construct(array $options = [])
{
$this->resolver = new OptionsResolver();
$this->configureOptions($this->resolver);
$this->options = $this->resolver->resolve($options);
}
/**
* Get cidr list
*
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
public function getCidrList(): array
{
return $this->options['cidrList'];
}
/**
* Get cidr project allowed list
*
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
public function getCidrAllowedList(): array
{
return $this->options['cidrProjectAllowedList'];
}
/**
* Configures the options of the client.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver The resolver for the options.
* @return void
*/
private function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'cidrList' => [],
'cidrProjectAllowedList' => []
]);
$resolver->setNormalizer('cidrList', \Closure::fromCallable([$this, 'normalizeCidrList']));
$resolver->setNormalizer('cidrProjectAllowedList', \Closure::fromCallable([$this, 'normalizeCidrProjectList']));
}
/**
* Normalise Cidr list for cidrList option
*
* @param \Symfony\Component\OptionsResolver\Options $options
* @param string|null $value
* @return array
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/
private function normalizeCidrList(
\Symfony\Component\OptionsResolver\Options $options,
?string $value
): array {
// phpcs:enable
return $this->doNormalizeCidrList($value, 'cidrList');
}
/**
* Normalise Cidr list for cidrProjectAllowedList option
*
* @param \Symfony\Component\OptionsResolver\Options $options
* @param string|null $value
* @return array
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/
private function normalizeCidrProjectList(
\Symfony\Component\OptionsResolver\Options $options,
?string $value
): array {
// phpcs:enable
return $this->doNormalizeCidrList($value, 'cidrProjectAllowedList');
}
/**
* Normalize CIDR list with specific cache key.
*
* @param string|null $value
* @param string $optionName
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
private function doNormalizeCidrList(?string $value, string $optionName): array
{
$cacheConfigKey = self::$cache_config_key . '_' . $optionName;
$allowed_cidr_config_list = collect(explode(',', strval($value)))->filter();
$allowed_cidr_config_list_hash = \md5($allowed_cidr_config_list->implode(','));
$allowed_cidr_list = [];
// Flush cache if config hash changed
if ($allowed_cidr_config_list_hash !== \collect(Cache::get($cacheConfigKey))->get('hash')) {
Cache::forget($cacheConfigKey);
/** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */
$allowed_cidr_list = $allowed_cidr_config_list
->map(function (string $cidr) {
$ip_range = !IPv4Range::Make($cidr)->isErr() ? IPv4Range::Make($cidr) : IPv6Range::Make($cidr);
if ($ip_range->isErr()) {
throw new \Exception(\trans(
'CIDR LIST not valid (ipv4 or ipv6 cidr) :cidr',
[
'cidr' => $cidr
]
));
}
return $ip_range->unwrap();
})->all();
}
/** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */
return \collect(Cache::rememberForever($cacheConfigKey, function() use ($allowed_cidr_list, $allowed_cidr_config_list_hash) {
return [
'list' => $allowed_cidr_list,
'hash' => $allowed_cidr_config_list_hash
];
}))->get('list');
}
}

View file

@ -15,8 +15,9 @@ class Promotion extends Model
* @var array
*/
protected $casts = [
'date_start' => 'datetime',
'date_end' => 'datetime',
'is_old_price_displayed' => 'boolean',
'date_start' => 'datetime',
'date_end' => 'datetime',
];
/**

View file

@ -11,6 +11,7 @@
"php": "^7.3",
"bumbummen99/shoppingcart": "^4.0",
"diglactic/laravel-breadcrumbs": "^6.1",
"dxw/cidr": "^3.1",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
@ -18,7 +19,6 @@
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5",
"ldc/ldccrmv2client": "^3.0",
"ldc/web-admin-secure-laravel": "^1.0",
"maatwebsite/excel": "^3.1",
"mews/purifier": "^3.3",
"sentry/sentry-laravel": "^3.7",

337
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f125859babe93c1c3b34a7e9b30cd499",
"content-hash": "d53d0cc95f99b7d1705ef16b912f287d",
"packages": [
{
"name": "asm89/stack-cors",
@ -715,6 +715,107 @@
],
"time": "2024-10-09T13:47:03+00:00"
},
{
"name": "dxw/cidr",
"version": "v3.1.2",
"source": {
"type": "git",
"url": "https://github.com/dxw/cidr.git",
"reference": "9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dxw/cidr/zipball/9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581",
"reference": "9cb82cb70f0d4a4a32b1b2e3e1ae005fba84d581",
"shasum": ""
},
"require": {
"dxw/result": "^1.0",
"php": "^7.2",
"phpseclib/phpseclib": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"mockery/mockery": "^1.3",
"peridot-php/leo": "^1.6",
"peridot-php/peridot": "^1.19",
"peridot-php/peridot-dot-reporter": "^1.0",
"vimeo/psalm": "^4.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Dxw\\CIDR\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "dxw",
"email": "team@govpress.com",
"homepage": "https://www.dxw.com"
}
],
"description": "IP address matching with CIDR ranges",
"homepage": "https://github.com/dxw/cidr",
"support": {
"issues": "https://github.com/dxw/cidr/issues",
"source": "https://github.com/dxw/cidr/tree/v3.1.2"
},
"time": "2021-04-13T15:13:30+00:00"
},
{
"name": "dxw/result",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/dxw/result.git",
"reference": "5b9d3988c215dc95e17cd082a33bc2c02b6007ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dxw/result/zipball/5b9d3988c215dc95e17cd082a33bc2c02b6007ca",
"reference": "5b9d3988c215dc95e17cd082a33bc2c02b6007ca",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"peridot-php/leo": "^1.6",
"peridot-php/peridot": "^1.19",
"peridot-php/peridot-dot-reporter": "^1.0",
"vimeo/psalm": "^3.2"
},
"type": "library",
"autoload": {
"psr-4": {
"Dxw\\Result\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mallory Adams",
"email": "mallory@dxw.com",
"homepage": "https://www.dxw.com/"
}
],
"description": "Result values",
"homepage": "https://github.com/dxw/result",
"support": {
"issues": "https://github.com/dxw/result/issues",
"source": "https://github.com/dxw/result/tree/master"
},
"time": "2020-06-12T16:01:47+00:00"
},
{
"name": "egulias/email-validator",
"version": "2.1.25",
@ -1672,66 +1773,6 @@
},
"time": "2022-07-28T15:18:54+00:00"
},
{
"name": "kwaadpepper/refresh-sitemap",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/Kwaadpepper/refresh-sitemap.git",
"reference": "4fdae6d0e9423f5af9216c74814929744807b6bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Kwaadpepper/refresh-sitemap/zipball/4fdae6d0e9423f5af9216c74814929744807b6bb",
"reference": "4fdae6d0e9423f5af9216c74814929744807b6bb",
"shasum": ""
},
"require": {
"illuminate/support": "~8",
"kwaadpepper/enum": "~2",
"laravel/framework": "~8",
"spatie/laravel-sitemap": "^5.8"
},
"require-dev": {
"slevomat/coding-standard": "^7.2"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Kwaadpepper\\RefreshSitemap\\RefreshSitemapServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Kwaadpepper\\RefreshSitemap\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jérémy Munsch",
"email": "github@jeremydev.ovh",
"homepage": "https://jeremydev.ovh"
}
],
"description": "Create sitemap.xml for all routes",
"homepage": "https://github.com/kwaadpepper/refresh-sitemap",
"keywords": [
"Sitemap",
"laravel"
],
"support": {
"issues": "https://github.com/Kwaadpepper/refresh-sitemap/issues",
"source": "https://github.com/Kwaadpepper/refresh-sitemap/tree/1.1.0"
},
"abandoned": "sitemap-refresh",
"time": "2023-03-06T08:27:09+00:00"
},
{
"name": "laravel/framework",
"version": "v8.83.29",
@ -2089,70 +2130,6 @@
"Laravel"
]
},
{
"name": "ldc/web-admin-secure-laravel",
"version": "1.0.1",
"source": {
"type": "git",
"url": "git@lab.s-web.fr:ldc-web/projets/ldc-web-admin-secure-laravel.git",
"reference": "c538f5d349b119ac64cb62b33e6368bef6be90bc"
},
"dist": {
"type": "zip",
"url": "https://lab.s-web.fr/api/v4/projects/20/packages/composer/archives/ldc/web-admin-secure-laravel.zip?sha=c538f5d349b119ac64cb62b33e6368bef6be90bc",
"reference": "c538f5d349b119ac64cb62b33e6368bef6be90bc",
"shasum": ""
},
"require": {
"illuminate/support": "~8|~9",
"laravel/framework": "~8|~9",
"php": "~7.3|7.4|~8"
},
"require-dev": {
"orchestra/testbench": "^6.24",
"phpunit/php-code-coverage": "^9.2",
"phpunit/phpunit": "~9.0",
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"LDC\\WebAdminSecureLaravel\\AdminSecureServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"LDC\\WebAdminSecureLaravel\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"LDC\\WebAdminSecureLaravel\\Tests\\": "tests"
}
},
"scripts": {
"test": [
"vendor/bin/phpunit"
],
"post-autoload-dump": [
"@php ./vendor/bin/testbench package:discover --ansi"
]
},
"license": [
"MIT"
],
"authors": [
{
"name": "Vincent BRIDIER",
"email": "vincent.bridier@ldc.fr",
"homepage": "https://www.ldc.fr"
}
],
"description": "Restrict access to LDC Network"
},
{
"name": "league/commonmark",
"version": "1.6.7",
@ -3885,6 +3862,116 @@
],
"time": "2024-07-20T21:41:07+00:00"
},
{
"name": "phpseclib/phpseclib",
"version": "2.0.51",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "ed661e7cdaeb8c419e609e2f3203551a13c2ed48"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/ed661e7cdaeb8c419e609e2f3203551a13c2ed48",
"reference": "ed661e7cdaeb8c419e609e2f3203551a13c2ed48",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
"squizlabs/php_codesniffer": "~2.0"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations.",
"ext-xml": "Install the XML extension to load XML formatted public keys."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/2.0.51"
},
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2026-01-27T09:11:52+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",

6
config/admin-secure.php Normal file
View file

@ -0,0 +1,6 @@
<?php
return [
'cidrList' => env('UWIL_ADMIN_SECURE_CIDR_LIST'),
'cidrProjectAllowedList' => env('UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST')
];

View file

@ -0,0 +1,29 @@
<?php
use App\Models\Product;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$products = Product::withTrashed()->orderBy('order')->get();
$order = 1;
foreach ($products as $product) {
$product->order = $order;
$product->saveOrFail();
$order++;
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Nothing to revert.
}
};

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddBooleanDisplayOldValueForPromotionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('promotions', function (Blueprint $table) {
$table->boolean('is_old_price_displayed')->comment('Should the old price be displayed ?')->after('discount_value');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('promotions', function (Blueprint $table) {
$table->dropColumn('is_old_price_displayed');
});
}
}

View file

@ -27,8 +27,7 @@ data:
CRM_PASSWORD: "${APP_CRM_PASSWORD}"
SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}"
MATOMO_SITE_ID: "${APP_MATOMO_SITE_ID}"
LDC_WEB_API_KEY: "${APP_LDC_WEB_API_KEY}"
LDC_WEB_CIDR_MANUAL_ALLOWED_LIST: "${APP_LDC_WEB_CIDR_MANUAL_ALLOWED_LIST}"
UWIL_ADMIN_SECURE_CIDR_LIST: "${APP_GLOBAL_UWIL_ADMIN_SECURE_CIDR_LIST}"
---
apiVersion: v1
kind: PersistentVolumeClaim

View file

@ -0,0 +1,23 @@
<td class="text-center align-middle">
<div class="d-flex justify-content-center align-items-center">
<b class="mx-3">{{ $value ?? '' }}</b>
<div class="dropdown">
<button class="btn btn-secondary" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-chevron-down"></i>
</button>
<div class="dropdown-menu">
<form class="px-4 py-3" action="{{ route('bo.product.change-selected-order', ['product' => $model]) }}" method="POST">
@csrf
@method('PATCH')
<div class="mb-3">
<label for="order-{{ $model->id }}" class="form-label">{{ __('Nouvelle position') }}</label>
<input type="number" class="form-input" id="order-{{ $model->id }}" placeholder="1" name="order" min="1">
</div>
<button type="submit" class="btn btn-primary">{{ _('Sauvegarder') }}</button>
</form>
</div>
</div>
</div>
</td>

View file

@ -71,7 +71,7 @@
<th></th>
</thead>
<tbody>
@foreach ($products as $product)
@foreach ($products as $key => $product)
<tr>
@if(count(Config::get('theme.enum_product_types'))>1)
<td>
@ -110,11 +110,9 @@
</button>
</form>
</td>
@php $routeName = request()->route()->getName(); @endphp
@include('bo.modules.change-model-order', [
'routeName' => 'products',
'models' => $products,
'model' => $product
@include('bo.modules.change-model-order-select', [
'model' => $product,
'value' => $key + 1 + ($products->currentPage() - 1) * $products->perPage(),
])
<td class="text-center">
<a href="{{ route('bo.products.edit', $product->id) }}" class="btn btn-sm btn-primary">Éditer</a>

View file

@ -40,7 +40,17 @@
<div class="form-group col">
<label for="discount_value">Valeur *</label>
<input type="number" id="discount_value" name="discount_value" min="0" step=".01" class="form-control" value="{{ old('discount_value') }}" required>
<small class="text-muted"> montant ou pourcentage de remise selon le type choisi </small>
<small class="text-muted"> Montant ou pourcentage de remise selon le type choisi </small>
</div>
<div class="form-group col">
<label for="is_old_price_displayed">Afficher l'ancien prix ?</label>
<input
type="checkbox"
id="is_old_price_displayed"
name="is_old_price_displayed"
class="form-check"
@if(old('is_old_price_displayed', false)) checked @endif>
<small class="text-muted"> Cocher pour afficher l'ancien prix </small>
</div>
<div class="form-group col">
<label for="date_start_date">Début <small class="text-muted"> de la promotion </small></label>

View file

@ -44,7 +44,18 @@
<div class="form-group col">
<label for="discount_value">Valeur *</label>
<input type="number" id="discount_value" name="discount_value" min="0" step=".01" class="form-control" value="{{ old('discount_value',$promotion->discount_value) }}" required>
<small class="text-muted"> montant ou pourcentage de remise selon le type choisi </small>
<small class="text-muted"> Montant ou pourcentage de remise selon le type choisi </small>
</div>
<div class="form-group col">
<label for="is_old_price_displayed">Afficher l'ancien prix ?</label><br>
<input
type="checkbox"
id="is_old_price_displayed"
name="is_old_price_displayed"
class="form-check"
@if(old('is_old_price_displayed', $promotion->is_old_price_displayed)) checked @endif>
<br>
<small class="text-muted"> Cocher pour afficher l'ancien prix </small>
</div>
<div class="form-group col">
<label for="date_start_date">Début <small class="text-muted"> de la promotion </small></label>

View file

@ -15,6 +15,7 @@
<thead>
<th scope="col">Type</th>
<th scope="col">Valeur</th>
<th scope="col">Ancien prix affiché ?</th>
<th scope="col">Début</th>
<th scope="col">Fin</th>
<th scope="col">Produits Concernés</th>
@ -25,6 +26,7 @@
<tr>
<td>{{$promotion->discountType->label}}</td>
<td>{{$promotion->discount_value}}</td>
<td>{{ $promotion->is_old_price_displayed ? 'Oui' : 'Non' }}</td>
<td>{{$promotion->date_start}}</td>
<td>{{$promotion->date_end}}</td>
<td>

View file

@ -31,7 +31,7 @@
<p class="card-price-new">
<span>@if ($product->weight_variable) Environ* @endif</span>
<span class="font-Barlow-bold h4 @if ($product->promotions->count()) text-red @endif">@fmt_currency($product->discountedPriceTtc)</span>
@if ($product->promotions->count())
@if ($product->promotions->count() && $product->promotions()->first()->is_old_price_displayed)
<span class="card-price-original position-relative me-2">@fmt_currency_without_ttc($product->priceTtc)</span>
@endif
<span class="text-lowercase">/{{ $product->sell_unit }}</span>
@ -44,9 +44,12 @@
@endif
<div class="card-action d-flex justify-content-center justify-content-lg-between align-items-center w-100">
<img class="card-action-nutriscore d-none d-lg-block" src="{{ asset(config('app.theme') . "/img/nutriscore/nutriscore-" . $product->foodProduct->nutriscore . ".png") }}">
@can('addToCart', $product)
@if(
Auth::guard('customer')->user() &&
Auth::guard('customer')->user()->can('addToCart', $product)
)
<basket-buttons :product-id='{{ $product->id }}'></basket-buttons>
@endcan
@endif
</div>
</div>
</div>

View file

@ -138,7 +138,11 @@
<div class="card-price d-flex flex-row justify-content-center align-items-center my-2">
<span v-if="product.weight_variable" class="me-1">Environ*</span>
<span class="card-price-new font-Barlow-bold h5" v-bind:class="{'text-red': product.promotion}">{{ currencyFormatter(product.discountedPriceTtc) }}</span>
<span v-if="product.promotion != null" class="card-price-original position-relative m-0 ms-2 m-lg-0 me-lg-2">{{ currencyFormatter(product.priceTtc) }}</span>
<span
v-if="product.promotion != null && product.promotion[0].is_old_price_displayed"
class="card-price-original position-relative m-0 ms-2 m-lg-0 me-lg-2">
{{ currencyFormatter(product.priceTtc) }}
</span>
<span class="text-lowercase ms-1">/{{ product.sell_unit }}</span>
</div>
<p class="fst-italic text-muted mb-2" v-if="product.weight_variable">*Produit vendu au kilo : {{ currencyFormatter(product.priceKgTtc) }} /kg</p>
@ -206,7 +210,8 @@
btnFilterCross: undefined,
btnSearch: undefined,
filters: [],
filtersMenuIsOpen: 0
filtersMenuIsOpen: 0,
shouldDisplayPrices: false,
}
},
mounted() {
@ -221,6 +226,7 @@
this.productsResults = jsonData.productsResults ?? 0;
this.filters = jsonData.filters ?? [];
this.filtersMenuIsOpen = jsonData.filtersMenuIsOpen ?? [];
this.shouldDisplayPrices = jsonData.shouldDisplayPrices ?? false;
this.selectFilters();
this.responsiveFilters();
this.countResults();
@ -400,6 +406,9 @@
if (isNaN(num)) {
return num;
}
if (!this.shouldDisplayPrices) {
return '-.--';
}
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(num);
}
}

View file

@ -20,7 +20,7 @@
{{ __('Offres') }}
</a>
<a class="nav-link @if (Route::is('products')) active @endif"
href="@if (Route::is('home')) {{config('app.url') }}#rayons @else {{ route('products') }} @endif">
href="{{ route('products') }}">
{{ __('Rayons') }}
</a>
<a class="nav-link @if (!Route::is('home')) d-none @endif"

View file

@ -5,10 +5,20 @@
<div class="swiper-wrapper">
@foreach ($slides as $slide)
<a class="swiper-slide d-flex justify-content-center align-items-center text-decoration-none px-2 px-md-5" href="{{ $slide->link }}">
<h2 class="title-medium font-Barlow-extra-bold text-center text-white px-2 px-md-5">{{ $slide->title }}</h2>
@if(!empty($slide->picture))
<img class="px-md-5" src="{{ asset('/storage/images/slides/' . $slide->picture) }}">
@endif
<div class="row">
<div @class([
"d-flex align-items-center justify-content-center col-12 order-2 order-lg-1",
"col-lg-3" => !empty($slide->picture),
"col-lg-10 col-lg-offset-1" => empty($slide->picture),
])>
<h2 class="fs-1 title-medium font-Barlow-extra-bold text-center text-white px-2">{{ $slide->title }}</h2>
</div>
@if(!empty($slide->picture))
<div class="col-12 col-lg-9 d-flex justify-content-center order-lg-2">
<img class="img-fluid" src="{{ asset('/storage/images/slides/' . $slide->picture) }}">
</div>
@endif
</div>
</a>
@endforeach
</div>

View file

@ -47,15 +47,18 @@
<p class="m-0">
<span>@if ($product->weight_variable) Environ* @endif</span>
<span class="@if ($product->promotions->count()) card-price-new @endif font-Barlow-bold h4 ms-1">@fmt_currency($product->discountedPriceTtc)</span>
@if ($product->promotions->count())
@if ($product->promotions->count() && $product->promotions()->first()->is_old_price_displayed)
<span class="card-price-original position-relative m-0 ms-2 m-lg-0 me-lg-2">@fmt_currency($product->priceTtc)</span>
@endif
<span class="text-lowercase">/{{ $product->sell_unit }}</span>
</p>
</div>
@can('addToCart', $product)
@if(
Auth::guard('customer')->user() &&
Auth::guard('customer')->user()->can('addToCart', $product)
)
<basket-buttons :product-id='{{$product->id}}'></basket-buttons>
@endcan
@endif
</div>
@if ($product->weight_variable)
<p class="fst-italic text-muted">*Produit vendu au kilo : @fmt_currency($product->priceKgTtc)/kg</p>

View file

@ -11,14 +11,15 @@
$dataComponent = [
'hasPromotion' => request()->promotion ? true : false,
'ranges' => $ranges,
'brands' => \App\Enums\ProductBrand::toArray(),
'brands' => $brands,
'tags' => $tags,
'products' => \App\Http\Resources\ProductResource::collection($products),
'productsResults' => $products->perPage(),
'productsCount' => $products->total(),
'search' => $sessionFilter->search ?? '',
'filters' => $sessionFilter,
'filtersMenuIsOpen' => $filtersMenuIsOpen
'filtersMenuIsOpen' => $filtersMenuIsOpen,
'shouldDisplayPrices' => \App\Helpers\BladeDirectivesHelper::shouldShowPrices(),
];
@endphp
<filter-component json-data='@json($dataComponent)'/>

View file

@ -5,17 +5,6 @@
&-container {
overflow: hidden;
}
&-slide {
h2 {
width: 60%;
}
img {
width: 40%;
max-width: 40rem;
}
}
}
}
@ -84,25 +73,6 @@
}
}
// SSSSSSSSSSSSSSS MMMMMMMM MMMMMMMM
// SS:::::::::::::::SM:::::::M M:::::::M
// S:::::SSSSSS::::::SM::::::::M M::::::::M
// S:::::S SSSSSSSM:::::::::M M:::::::::M
// S:::::S M::::::::::M M::::::::::M
// S:::::S M:::::::::::M M:::::::::::M
// S::::SSSS M:::::::M::::M M::::M:::::::M
// SS::::::SSSSS M::::::M M::::M M::::M M::::::M
// SSS::::::::SS M::::::M M::::M::::M M::::::M
// SSSSSS::::S M::::::M M:::::::M M::::::M
// S:::::SM::::::M M:::::M M::::::M
// S:::::SM::::::M MMMMM M::::::M
// SSSSSSS S:::::SM::::::M M::::::M
// S::::::SSSSSS:::::SM::::::M M::::::M
// S:::::::::::::::SS M::::::M M::::::M
// SSSSSSSSSSSSSSS MMMMMMMM MMMMMMMM
@include media-breakpoint-up(sm) { //576px
//
}
// MMMMMMMM MMMMMMMMDDDDDDDDDDDDD
// M:::::::M M:::::::MD::::::::::::DDD
// M::::::::M M::::::::MD:::::::::::::::DD
@ -227,41 +197,3 @@
}
}
}
// XXXXXXX XXXXXXXLLLLLLLLLLL
// X:::::X X:::::XL:::::::::L
// X:::::X X:::::XL:::::::::L
// X::::::X X::::::XLL:::::::LL
// XXX:::::X X:::::XXX L:::::L
// X:::::X X:::::X L:::::L
// X:::::X:::::X L:::::L
// X:::::::::X L:::::L
// X:::::::::X L:::::L
// X:::::X:::::X L:::::L
// X:::::X X:::::X L:::::L
// XXX:::::X X:::::XXX L:::::L LLLLLL
// X::::::X X::::::XLL:::::::LLLLLLLLL:::::L
// X:::::X X:::::XL::::::::::::::::::::::L
// X:::::X X:::::XL::::::::::::::::::::::L
// XXXXXXX XXXXXXXLLLLLLLLLLLLLLLLLLLLLLLL
@include media-breakpoint-up(xl) { //1200px
//
}
// XXXXXXX XXXXXXXXXXXXXX XXXXXXXLLLLLLLLLLL
// X:::::X X:::::XX:::::X X:::::XL:::::::::L
// X:::::X X:::::XX:::::X X:::::XL:::::::::L
// X::::::X X::::::XX::::::X X::::::XLL:::::::LL
// XXX:::::X X:::::XXXXXX:::::X X:::::XXX L:::::L
// X:::::X X:::::X X:::::X X:::::X L:::::L
// X:::::X:::::X X:::::X:::::X L:::::L
// X:::::::::X X:::::::::X L:::::L
// X:::::::::X X:::::::::X L:::::L
// X:::::X:::::X X:::::X:::::X L:::::L
// X:::::X X:::::X X:::::X X:::::X L:::::L
// XXX:::::X X:::::XXXXXX:::::X X:::::XXX L:::::L LLLLLL
// X::::::X X::::::XX::::::X X::::::XLL:::::::LLLLLLLLL:::::L
// X:::::X X:::::XX:::::X X:::::XL::::::::::::::::::::::L
// X:::::X X:::::XX:::::X X:::::XL::::::::::::::::::::::L
// XXXXXXX XXXXXXXXXXXXXX XXXXXXXLLLLLLLLLLLLLLLLLLLLLLLL
@include media-breakpoint-up(xxl) { //1400px
//
}

View file

@ -14,8 +14,8 @@ return [
'range_image_large_maxheight' => '500',
'content_banner_maxwidth' => '100',
'content_banner_maxheight' => '100',
'slide_image_maxwidth' => '500',
'slide_image_maxheight' => '500',
'slide_image_maxwidth' => '830',
'slide_image_maxheight' => '320',
'register_mode' => ['public', 'salaries'],
/**
* attention ce paramètre est un paramètre de fonctionnement

View file

@ -32,7 +32,11 @@ Route::name('auth.')
Route::prefix('bo')
->name('bo.')
->middleware(['auth', 'is-admin', 'admin-secure'])
->middleware([
'auth',
'is-admin',
'admin-secure'
])
->group(function () {
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
Route::match(['get', 'put'], '/content/{key}', [ContentController::class, 'manage'])
@ -71,6 +75,10 @@ Route::prefix('bo')
->name('products.change-published');
Route::get('/products/change-order/{product}/{direction}', [ProductsController::class, 'changeOrder'])
->where('direction', 'up|down')->name('products.change-order');
Route::patch('/products/{product}/change-selected-order', [
ProductsController::class,
'changeSelectedOrder'
])->name('product.change-selected-order');
// Slides.
Route::resource('slides', SlidesController::class)->except(['show']);
Route::resource('sliders', SlidersController::class)->except(['show']);