This commit is contained in:
denisdulici
2018-07-01 21:06:52 +03:00
parent 19dc25d84f
commit 6f2c936a73
3 changed files with 47 additions and 25 deletions

View File

@ -2,36 +2,11 @@
namespace App\Http\Requests;
use App\Models\Setting\Currency;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Factory as ValidationFactory;
class Request extends FormRequest
{
private $currency_code;
public function __construct(ValidationFactory $validation)
{
$validation->extend(
'currency',
function ($attribute, $currency_code, $parameters) {
$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
$this->currency_code = $currency_code;
return $currency;
},
trans('validation.custom.invalid_currency', ['attribute' => $this->currency_code])
);
}
/**
* Set the company id to the request.
*