method()) { case 'POST': return $this->getPostRules(); break; case 'PUT': return $this->getPutRules(); break; default: return []; } } private function getPostRules() { return [ 'centro_custo_id_de' => [ 'required', 'integer', 'different:centro_custo_id_para', Rule::unique('\App\Models\PainelSenha\Encaminhamento')->where(function ($query) { return $query ->where('centro_custo_id_para', $this->centro_custo_id_para) ->whereNull('deleted_at'); }), ], 'centro_custo_id_para' => [ 'required', 'integer', 'different:centro_custo_id_de', ], ]; } private function getPutRules() { return [ 'centro_custo_id_de' => [ 'required', 'integer', 'different:centro_custo_id_para', Rule::unique('\App\Models\PainelSenha\Encaminhamento')->where(function ($query) { return $query ->where('centro_custo_id_para', $this->centro_custo_id_para) ->whereNull('deleted_at'); })->ignore($this->encaminhamento), ], 'centro_custo_id_para' => [ 'required', 'integer', 'different:centro_custo_id_de', ], ]; } public function messages() { return [ 'centro_custo_id_de.unique' => 'Já existe um encaminhamento cadastrado com estas informações.' ]; } }