46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Buttons;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class ViewTopUp extends Component
|
|
{
|
|
public $uuid;
|
|
public $fee_code,
|
|
$name,
|
|
$type,
|
|
$amount;
|
|
|
|
public function mount($uuid)
|
|
{
|
|
$this->uuid = $uuid;
|
|
|
|
$token = Session::get('user.access_token');
|
|
|
|
if (!$token) {
|
|
$this->addError('users', 'No access token found.');
|
|
return;
|
|
}
|
|
|
|
$response = Http::withToken($token)->get(config('services.backend_api.url') . "/api/cms/topUp/{$uuid}");
|
|
|
|
if ($response->successful()) {
|
|
$topUp = $response->json('data');
|
|
|
|
$this->fee_code = $topUp['fee_code'] ?? '';
|
|
$this->name = $topUp['name'] ?? '';
|
|
$this->type = $topUp['type'] ?? '';
|
|
$this->amount = $topUp['amount'] ?? 0;
|
|
} else {
|
|
$this->addError('top ups', 'Failed to fetch top up data.');
|
|
}
|
|
}
|
|
public function render()
|
|
{
|
|
return view('livewire.buttons.view-top-up');
|
|
}
|
|
}
|