42 lines
1,022 B
PHP
42 lines
1,022 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Lib\Inputs;
|
||
|
|
|
||
|
|
use App\Enums\Formularies\InputTypeEnum;
|
||
|
|
use App\Lib\Inputs\Definition\Input;
|
||
|
|
use Illuminate\Contracts\Validation\Validator;
|
||
|
|
use Illuminate\Support\Facades\Validator as FacadesValidator;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @inheritDoc Phone
|
||
|
|
* @package App\Lib\Inputs
|
||
|
|
*/
|
||
|
|
class InputPhone extends Input
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Get the matching enum for this object
|
||
|
|
*
|
||
|
|
* @return \App\Enums\Formularies\InputTypeEnum
|
||
|
|
*/
|
||
|
|
public static function getType(): InputTypeEnum
|
||
|
|
{
|
||
|
|
return InputTypeEnum::phone();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validator this input
|
||
|
|
*
|
||
|
|
* @param string|array $data The line with data.
|
||
|
|
* @param boolean $required The line is required.
|
||
|
|
* @return \Illuminate\Contracts\Validation\Validator
|
||
|
|
*/
|
||
|
|
public static function getValidator($data, bool $required): Validator
|
||
|
|
{
|
||
|
|
return FacadesValidator::make(
|
||
|
|
['value' => $data],
|
||
|
|
['value' => ($required ? 'required' : 'nullable') . '|string|max:255']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|