- Introduced `LogisticsApiException` to handle connection and request errors with user-friendly messages in French. - Updated `LogisticsService` to include configurable timeout, connection timeout, retry attempts, and sleep duration for retries. - Enhanced error handling in Filament pages to catch `LogisticsApiException` and provide clear feedback to users. - Updated `.env` and `config/logistics.php` to support new configuration options. - Added logging for failed API requests in `api_request_logs`. - Created comprehensive API documentation for Logistics endpoints.
73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Exceptions\LogisticsApiException;
|
|
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 (LogisticsApiException $e) {
|
|
$this->errorMessage = $e->getMessage();
|
|
} catch (\Throwable $e) {
|
|
$this->errorMessage = "Erreur inattendue : {$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 (LogisticsApiException $e) {
|
|
$this->errorMessage = $e->getMessage();
|
|
} catch (\Throwable $e) {
|
|
$this->errorMessage = "Erreur inattendue : {$e->getMessage()}";
|
|
}
|
|
}
|
|
}
|