2019-11-11 13:21:19 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-11-11 13:21:19 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-11-11 13:21:19 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\ValidationRules;
|
|
|
|
|
|
|
|
use App\Utils\Traits\CompanyGatewayFeesAndLimitsSaver;
|
|
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class ValidCompanyGatewayFeesAndLimitsRule.
|
2019-11-11 13:21:19 +01:00
|
|
|
*/
|
|
|
|
class ValidCompanyGatewayFeesAndLimitsRule implements Rule
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
use CompanyGatewayFeesAndLimitsSaver;
|
2019-11-11 13:21:19 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $attribute
|
|
|
|
* @param mixed $value
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public $return_data;
|
|
|
|
|
|
|
|
public function passes($attribute, $value)
|
|
|
|
{
|
|
|
|
$data = $this->validateFeesAndLimits($value);
|
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
if (is_array($data)) {
|
2019-11-11 13:21:19 +01:00
|
|
|
$this->return_data = $data;
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-11-11 13:21:19 +01:00
|
|
|
return false;
|
2019-12-30 22:59:12 +01:00
|
|
|
} else {
|
2019-11-11 13:21:19 +01:00
|
|
|
return true;
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-11-11 13:21:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function message()
|
|
|
|
{
|
2020-09-06 11:38:10 +02:00
|
|
|
return $this->return_data[0].' is not a valid '.$this->return_data[1];
|
2019-11-11 13:21:19 +01:00
|
|
|
}
|
|
|
|
}
|