42 lines
1014 B
PHP
42 lines
1014 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Reports;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class RegistrationList 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/reportRegistration');
|
|
if ($response->successful()) {
|
|
$this->data = $response->json()['data'] ?? [];
|
|
} else {
|
|
$this->alert('error', 'Failed to fetch registration report data.');
|
|
}
|
|
} catch (\Exception $e) {
|
|
$this->alert('error', 'An error occurred: ' . $e->getMessage());
|
|
} finally {
|
|
$this->updating = false;
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.reports.registration-list')->layout('layouts.app', ['title' => 'Registration Report']);
|
|
}
|
|
}
|