48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\MemberManagement;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Jantinnerezo\LivewireAlert\LivewireAlert;
|
|
|
|
class LockAccountList extends Component
|
|
{
|
|
use LivewireAlert;
|
|
|
|
public $accounts = [];
|
|
|
|
public function mount()
|
|
{
|
|
// Placeholder role check
|
|
// if (auth()->user()->role != 1) {
|
|
// $this->alert('error', 'Unauthorized access.');
|
|
// return redirect('/');
|
|
// }
|
|
$this->fetchAccounts();
|
|
}
|
|
|
|
public function fetchAccounts()
|
|
{
|
|
try {
|
|
$response = Http::get('https://api.example.com/member', [
|
|
'_locked' => 1,
|
|
'_sort_by' => 'card_number',
|
|
'_sort_order' => 'asc',
|
|
]);
|
|
if ($response->successful()) {
|
|
$this->accounts = $response->json()['data'] ?? [];
|
|
} else {
|
|
$this->alert('error', 'Failed to fetch locked accounts.');
|
|
}
|
|
} catch (\Exception $e) {
|
|
$this->alert('error', 'An error occurred: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.member-management.lock-account-list')->layout('layouts.app', ['title' => 'Locked Accounts']);
|
|
}
|
|
}
|