32 lines
996 B
PHP
32 lines
996 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
|
|
|
class SaveCustomerCollectionRequest extends CustomerCollectionRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$idEnumRule = '';
|
|
return array_merge(
|
|
parent::rules(),
|
|
[ 'id' => [
|
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
function ($attribute, $value, $fail) use (&$idEnumRule) {
|
|
if (!array_key_exists($this->type->value, $this->maps)) {
|
|
$fail(__CLASS__ . ' does not handle ' . get_class($this->type) . ' please add it.');
|
|
} else {
|
|
$idEnumRule = new EnumIsValidRule($this->maps[$this->type->value]);
|
|
}
|
|
},
|
|
$idEnumRule
|
|
]]
|
|
);
|
|
}
|
|
}
|