116 lines
3.1 KiB
PHP
116 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Parametrizacao;
|
|
|
|
use App\Http\Requests\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ExameRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
if (request()->has('action') && request()->action === 'atribuicao-parametro-grupo') {
|
|
return [];
|
|
} else {
|
|
switch ($this->method()) {
|
|
|
|
case 'POST':
|
|
case 'PUT': {
|
|
|
|
return $this->getPostPutRules();
|
|
}
|
|
default: {
|
|
|
|
return [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private function getPostPutRules()
|
|
{
|
|
return [
|
|
'nome' => [
|
|
'required',
|
|
'string',
|
|
'between:3,180',
|
|
Rule::unique('\App\Models\Parametrizacao\Exame\Exame', 'nome')
|
|
->where(function ($query) {
|
|
|
|
return $query->whereNull('deleted_at');
|
|
})
|
|
->ignore($this->exame)
|
|
],
|
|
'tipo_id' => [
|
|
'required'
|
|
],
|
|
'sigla_exame' => [
|
|
'required',
|
|
'string',
|
|
'between:2,5',
|
|
],
|
|
'prazo_entrega' => [
|
|
'integer',
|
|
'max:999'
|
|
],
|
|
'validade' => [
|
|
'integer',
|
|
'max:999'
|
|
],
|
|
'quantidade_maxima' => [
|
|
'integer',
|
|
'max:99999'
|
|
],
|
|
'ultimo_resultado' => [
|
|
'integer',
|
|
'max:99'
|
|
],
|
|
'resultado' => [
|
|
'max:500',
|
|
],
|
|
'regulacao_tipo_id' => [
|
|
'nullable',
|
|
'integer',
|
|
],
|
|
'is_ppi' => [
|
|
'required',
|
|
'boolean',
|
|
],
|
|
'tempo_medio_previsto_atendimento_dias' => [
|
|
'nullable',
|
|
'integer',
|
|
'max:9999'
|
|
],
|
|
];
|
|
}
|
|
|
|
public function messages()
|
|
{
|
|
return [
|
|
'nome.unique' => 'O nome do Exame já foi inserido anteriormente.',
|
|
'sigla_exame.max' => 'O limite de caracteres foi atingido na sigla do exame.',
|
|
'sigla_exame.required' => 'Obrigatório informar a sigla do exame.',
|
|
'prazo_entrega.max' => 'O limite de caracteres foi atingido no prazo de entrega.',
|
|
'validade.max' => 'O limite de caracteres foi atingido na validade.',
|
|
'quantidade_maxima.max' => 'O limite de caracteres foi atingido na quantidade máxima.',
|
|
'ultimo_resultado.max' => 'O limite de caracteres foi atingido no últimos resultados.',
|
|
'resultado.max' => 'O limite de caracteres foi atingido no resultado.',
|
|
];
|
|
}
|
|
}
|