diff --git a/app/Http/Controllers/Fo/OrderController.php b/app/Http/Controllers/Fo/OrderController.php index 32f190d..12b25b6 100644 --- a/app/Http/Controllers/Fo/OrderController.php +++ b/app/Http/Controllers/Fo/OrderController.php @@ -17,9 +17,9 @@ use App\Http\Requests\Fo\Orders\SetOrderTimeSlotRequest; use App\Http\Requests\Fo\Orders\ShippingFormRequest; use App\Http\Requests\Fo\Orders\ShippingModeFormRequest; use App\Http\Resources\ShopResource; +use App\Lib\Helpers\ToolboxHelper; use App\Mail\NewOrderIncome; use App\Models\Customer\Customer; -use App\Models\Merchandise\Product; use App\Models\Payment\Transaction; use App\Models\Shop\DeliveryMode; use App\Models\Site\GeneralConfig; @@ -721,7 +721,7 @@ class OrderController extends Controller if ($sampleOrder->total_ttc < $minAmountForTransaction) { \redirect()->route('home') ->with('warning', trans('Le montant minimal pour une commande est de :minAmount', [ - 'minAmount' => Product::fmtCurrency($minAmountForTransaction) + 'minAmount' => ToolboxHelper::fmtCurrency($minAmountForTransaction) ]))->throwResponse(); } } diff --git a/app/Lib/Helpers/ToolboxHelper.php b/app/Lib/Helpers/ToolboxHelper.php index bce4eec..80744c3 100644 --- a/app/Lib/Helpers/ToolboxHelper.php +++ b/app/Lib/Helpers/ToolboxHelper.php @@ -12,10 +12,38 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Illuminate\Validation\Rule; use Illuminate\Validation\ValidationException; +use Money\Money; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class ToolboxHelper { + /** + * Get displayable price value + * + * @param mixed $value Amount in cents. + * @param string $suffix Append some text. + * @return string + */ + public static function fmtCurrency($value, string $suffix = 'TTC'): string + { + return \trim(sprintf( + '%s %s', + app('phpMoneyFormatter')->format(new Money($value, app('phpMoneyCurrency'))), + $suffix + )); + } + + /** + * Get displayable price value + * + * @param mixed $value + * @return string + */ + public static function fmtSellUnit($value): string + { + return !empty($value) ? "/ {$value}" : ''; + } + /** * Generate an unique reference from model on reference column by default * diff --git a/app/Models/Merchandise/Product.php b/app/Models/Merchandise/Product.php index 380a13d..9bccc5e 100644 --- a/app/Models/Merchandise/Product.php +++ b/app/Models/Merchandise/Product.php @@ -692,33 +692,4 @@ class Product extends Model implements Buyable // @phpcs:enable return $this->weight; } - - // * METHODS - - /** - * Get displayable price value - * - * @param mixed $value - * @param string $suffix - * @return string - */ - public static function fmtCurrency($value, string $suffix = 'TTC'): string - { - return sprintf( - '%s € %s', - number_format(\intval($value) / 100, 2, ',', ' '), - $suffix - ); - } - - /** - * Get displayable price value - * - * @param mixed $value - * @return string - */ - public static function fmtSellUnit($value): string - { - return !empty($value) ? "/ {$value}" : ''; - } } diff --git a/resources/theme b/resources/theme index c8038a6..bd61a50 160000 --- a/resources/theme +++ b/resources/theme @@ -1 +1 @@ -Subproject commit c8038a68ea57e586160ddcf902606b520d140727 +Subproject commit bd61a507a675d85be6ac7d3c80f915ddb2195211 diff --git a/resources/views/pages/discounts/indexList.blade.php b/resources/views/pages/discounts/indexList.blade.php index 233118e..8e5b5e4 100644 --- a/resources/views/pages/discounts/indexList.blade.php +++ b/resources/views/pages/discounts/indexList.blade.php @@ -57,8 +57,8 @@ src="{{ asset(resize($product->picture, 'boStickers')) }}" alt="{{ Str::limit($product->name, 15) }}">