diff --git a/.gitignore b/.gitignore index 35b1eceb9..9b45324f8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,10 @@ yarn-error.log /.vscode /.docker .DS_Store -config/app.php +app/Http/Requests/RegisterRequest.php +public/build/manifest.json +public/build/assets/app-8a9a9028.js +.gitignore +tests/Feature/CriteriaMountTest.php +public/build/manifest.json + diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index fe0303a00..67083a161 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -3,8 +3,6 @@ namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Support\Facades\Http; -use Illuminate\Support\Facades\Log; class RegisterRequest extends FormRequest { @@ -23,42 +21,43 @@ public function rules(): array 'username' => 'required|max:255|min:2', 'password' => 'required|min:5|max:255', 'terms' => 'required', - 'g-recaptcha-response' => 'required', // Campo do reCAPTCHA + // 'g-recaptcha-response' => 'required', // Campo do reCAPTCHA desativado ]; } public function messages(): array { return [ - 'g-recaptcha-response.required' => 'A verificação de reCAPTCHA é necessária.', + // 'g-recaptcha-response.required' => 'A verificação de reCAPTCHA é necessária.', // Mensagem desativada ]; } public function withValidator($validator) { $validator->after(function ($validator) { - if (!$this->validateRecaptcha()) { - $validator->errors()->add('g-recaptcha-response', 'Falha na verificação do reCAPTCHA. Tente novamente.'); - } + // Validação do reCAPTCHA desativada + // if (!$this->validateRecaptcha()) { + // $validator->errors()->add('g-recaptcha-response', 'Falha na verificação do reCAPTCHA. Tente novamente.'); + // } }); } - private function validateRecaptcha(): bool - { - $response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [ - 'secret' => config('services.recaptcha.secret_key'), - 'response' => $this->input('g-recaptcha-response'), - 'remoteip' => $this->ip(), - ]); - - $result = $response->json(); + // Método de validação do reCAPTCHA desativado + // private function validateRecaptcha(): bool + // { + // $response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [ + // 'secret' => config('services.recaptcha.secret_key'), + // 'response' => $this->input('g-recaptcha-response'), + // 'remoteip' => $this->ip(), + // ]); - if (!($result['success'] ?? false) || ($result['score'] ?? 0) < 0.3) { - Log::error('reCAPTCHA falhou', ['response' => $result]); // Log de erro detalhado - return false; - } + // $result = $response->json(); - return true; - } + // if (!($result['success'] ?? false) || ($result['score'] ?? 0) < 0.3) { + // Log::error('reCAPTCHA falhou', ['response' => $result]); // Log de erro detalhado + // return false; + // } + // return true; + // } } diff --git a/app/Livewire/Planning/Criteria/Criteria.php b/app/Livewire/Planning/Criteria/Criteria.php index c0434a373..40a625d9b 100644 --- a/app/Livewire/Planning/Criteria/Criteria.php +++ b/app/Livewire/Planning/Criteria/Criteria.php @@ -79,22 +79,46 @@ protected function messages() */ public function mount() { - $projectId = request()->segment(2); - $this->currentProject = ProjectModel::findOrFail($projectId); - $this->currentCriteria = null; - $this->criterias = CriteriaModel::where( - 'id_project', - $this->currentProject->id_project - )->get(); - $this->inclusion_rule['value'] = CriteriaModel::where( - 'id_project', - $this->currentProject->id_project - )->where('type', 'Inclusion')->first()->rule ?? 'ALL'; - $this->exclusion_rule['value'] = CriteriaModel::where( - 'id_project', - $this->currentProject->id_project - )->where('type', 'Exclusion')->first()->rule ?? 'ANY'; - $this->type['value'] = null; + try { + $projectId = request()->segment(2); + + // Verifica se o projeto existe + $this->currentProject = ProjectModel::findOrFail($projectId); + + // Inicializa os critérios + $this->criterias = CriteriaModel::where( + 'id_project', + $this->currentProject->id_project + )->get(); + + // Define as regras de inclusão e exclusão com fallback + $this->inclusion_rule['value'] = CriteriaModel::where( + 'id_project', + $this->currentProject->id_project + )->where('type', 'Inclusion')->first()->rule ?? 'ALL'; + + $this->exclusion_rule['value'] = CriteriaModel::where( + 'id_project', + $this->currentProject->id_project + )->where('type', 'Exclusion')->first()->rule ?? 'ANY'; + + // Define o tipo padrão + $this->type['value'] = 'NONE'; + } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { + // Caso o projeto não seja encontrado + $this->toast( + message: __('O projeto não foi encontrado.'), + type: 'error' + ); + return redirect()->route('projects.index'); // Redireciona para a lista de projetos + } catch (\Exception $e) { + // Captura outros erros inesperados + $this->toast( + message: __('Ocorreu um erro ao carregar os dados: ') . $e->getMessage(), + type: 'error' + ); + } + } /**