FleetCart/Modules/Coupon/Exceptions/MinimumSpendException.php

42 lines
814 B
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Coupon\Exceptions;
use Exception;
2023-12-03 14:07:47 +00:00
use Modules\Support\Money;
use Illuminate\Http\Response;
2023-06-11 12:14:03 +00:00
class MinimumSpendException extends Exception
{
/**
* The amount that need to spend.
*
2023-12-03 14:07:47 +00:00
* @var Money
2023-06-11 12:14:03 +00:00
*/
private $money;
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
/**
* Create a new instance of the exceptions
*
2023-12-03 14:07:47 +00:00
* @param Money $money
2023-06-11 12:14:03 +00:00
*/
public function __construct($money)
{
$this->money = $money;
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
/**
* Render the exception into an HTTP response.
*
2023-12-03 14:07:47 +00:00
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function render()
{
return response()->json([
'message' => trans('coupon::messages.minimum_spend', ['amount' => $this->money->convertToCurrentCurrency()->format()]),
], 403);
}
}