init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Http\Requests\Cadastro\Estabelecimento;
use App\Http\Requests\FormRequest;
use Illuminate\Validation\Rule;
class SetorRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
switch($this->method()) {
case 'POST':
return $this->getPostRules();
case 'PUT':
return $this->getPutRules();
default:
return [];
}
}
private function getPostRules()
{
return [
'tipo_id' => ['required'],
'servico_id' => ['required', 'integer'],
'nome' => [
'required',
'string',
'between:3,180',
Rule::unique('\App\Models\Cadastro\Estabelecimento\Setor')->where(function ($query) {
return $query
->where('servico_id', $this->servico_id)
->whereNull('deleted_at');
}),
]
];
}
private function getPutRules()
{
return [
'tipo_id' => ['required'],
'servico_id' => ['required', 'integer'],
'nome' => [
'required',
'string',
'between:3,180',
Rule::unique('\App\Models\Cadastro\Estabelecimento\Setor')->where(function ($query) {
return $query
->where('servico_id', $this->servico_id)
->whereNull('deleted_at');
})->ignore($this->setor),
],
];
}
public function messages()
{
return [
'nome.unique' => 'Um Setor com o mesmo Serviço e Nome já foi inserido anteriormente.'
];
}
}