fetchSliders(); $this->checkLimit(); } public function fetchSliders() { try { $this->sliders = $this->fetchFromApi('https://api.example.com/photoSlider?page=1&page_size=10&_sort_by=create_dt&_sort_order=desc'); } catch (\Exception $e) { session()->flash('error', 'Failed to load photo sliders: ' . $e->getMessage()); } } public function checkLimit() { try { $response = \Http::get('https://api.example.com/photoSliderCount'); $this->photoSliderLimit = $response->json()['data'] >= 10; } catch (\Exception $e) { $this->photoSliderLimit = true; // Default to true if API fails } } private function fetchFromApi($url) { $response = \Http::get($url); return $response->json()['data'] ?? []; } public function delete($uuid) { try { $response = \Http::delete("https://api.example.com/photoSlider/{$uuid}"); if ($response->successful()) { session()->flash('success', 'Record was successfully deleted.'); $this->fetchSliders(); $this->checkLimit(); } } catch (\Exception $e) { session()->flash('error', 'Failed to delete record: ' . $e->getMessage()); } } public function render() { return view('livewire.photo-slider.photo-slider-list'); } }