isRetraining = true; $this->showOutput = true; try { $response = Http::get('http://127.0.0.1:8000/retrain-model'); $data = $response->json(); if ($response->successful()) { $this->retrainingOutput = $data['details'] ?? $data['message']; $this->hasError = false; $this->dispatch('retrain-success'); } else { $this->retrainingOutput = $data['error'] ?? 'An unknown error occurred'; $this->hasError = true; } } catch (\Exception $e) { $this->retrainingOutput = "Failed to connect to the retraining service."; $this->hasError = true; } finally { $this->isRetraining = false; } } #[On('retrain-success')] public function getSpecies() { try { // get species from API $response = Http::get('http://127.0.0.1:8000/species'); if ($response->successful()) { $species = $response->json(); // loop through the species from the API foreach ($species as $speciesName) { // check if the species already exists in the database if (!Species::where('name', $speciesName)->exists()) { // insert the species if it does not exist Species::create(['name' => $speciesName]); } } $this->syncMessage = 'Species list successfully synchronized.'; } else { throw new \Exception('Failed to fetch species from API'); } } catch (\Exception $e) { $this->syncMessage = 'Failed to synchronize species list: ' . $e->getMessage(); $this->hasError = true; } } }; ?>

{{ __('Retrain Model') }}

{{ __("Retrain the model with the latest dataset to improve predictions.") }}

{{ __('Retrain Model') }} {{ __('Retraining...') }}
@if($showOutput)
@if($hasError) @else @endif

{{ $hasError ? 'Retraining Failed' : 'Retraining Succeeded' }}

                    {{ $retrainingOutput }}
@endif