68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Services\LogisticsService;
|
|
use Filament\Pages\Page;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Livewire\Attributes\Url;
|
|
|
|
class TablesExplorer extends Page
|
|
{
|
|
protected static string|\BackedEnum|null $navigationIcon = Heroicon::OutlinedTableCells;
|
|
|
|
protected static ?string $navigationLabel = 'Tables';
|
|
|
|
protected static ?string $title = 'Explorateur de tables';
|
|
|
|
protected static ?int $navigationSort = 1;
|
|
|
|
protected string $view = 'filament.pages.tables-explorer';
|
|
|
|
#[Url]
|
|
public string $selectedTable = '';
|
|
|
|
public array $tables = [];
|
|
|
|
public array $columns = [];
|
|
|
|
public ?string $errorMessage = null;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->loadTables();
|
|
}
|
|
|
|
public function loadTables(): void
|
|
{
|
|
try {
|
|
$service = app(LogisticsService::class);
|
|
$response = $service->tablesList();
|
|
|
|
$this->tables = $response['data'] ?? [];
|
|
$this->errorMessage = $response['error'] ?? null;
|
|
} catch (\Throwable $e) {
|
|
$this->errorMessage = $e->getMessage();
|
|
}
|
|
}
|
|
|
|
public function loadColumns(): void
|
|
{
|
|
if (blank($this->selectedTable)) {
|
|
$this->columns = [];
|
|
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$service = app(LogisticsService::class);
|
|
$response = $service->columnList($this->selectedTable);
|
|
|
|
$this->columns = $response['data'] ?? [];
|
|
$this->errorMessage = $response['error'] ?? null;
|
|
} catch (\Throwable $e) {
|
|
$this->errorMessage = $e->getMessage();
|
|
}
|
|
}
|
|
}
|