44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\AboutUs\TermAndPrivacy;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class TermAndPrivacyList extends Component
|
|
{
|
|
public $terms = [];
|
|
|
|
public function mount()
|
|
{
|
|
$this->fetchTerms();
|
|
}
|
|
|
|
public function fetchTerms()
|
|
{
|
|
try {
|
|
$response = Http::get('https://api.example.com/TermsAndPrivacy?page=1&page_size=10&_sort_by=create_dt&_sort_order=desc');
|
|
$this->terms = $response->json()['data'] ?? [];
|
|
} catch (\Exception $e) {
|
|
session()->flash('error', 'Failed to load terms and privacy: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function delete($uuid)
|
|
{
|
|
try {
|
|
$response = Http::delete("https://api.example.com/TermsAndPrivacy/{$uuid}");
|
|
if ($response->successful()) {
|
|
session()->flash('success', 'Record was successfully deleted.');
|
|
$this->fetchTerms();
|
|
}
|
|
} catch (\Exception $e) {
|
|
session()->flash('error', 'Failed to delete record: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.about-us.term-and-privacy.term-and-privacy-list');
|
|
}
|
|
} |