cms-laravel/app/Livewire/Reports/StationRatingList.php

42 lines
1023 B
PHP

<?php
namespace App\Livewire\Reports;
use Livewire\Component;
use Illuminate\Support\Facades\Http;
class StationRatingList extends Component
{
public $data = [];
public $updating = false;
public function mount()
{
$this->fetchData();
}
public function fetchData()
{
try {
$this->updating = true;
$response = Http::get('https://api.example.com/reportStationRatings');
if ($response->successful()) {
$this->data = $response->json()['data'] ?? [];
} else {
$this->alert('error', 'Failed to fetch station rating report data.');
}
} catch (\Exception $e) {
$this->alert('error', 'An error occurred: ' . $e->getMessage());
} finally {
$this->updating = false;
}
}
public function render()
{
return view('livewire.reports.station-rating-list')->layout('layouts.app', ['title' => 'Station Rating Report']);
}
}