🎉 First commit
This commit is contained in:
75
app/Filament/Pages/Documents.php
Normal file
75
app/Filament/Pages/Documents.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Services\LogisticsService;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Documents extends Page
|
||||
{
|
||||
protected static string|\BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentText;
|
||||
|
||||
protected static ?string $navigationLabel = 'Documents';
|
||||
|
||||
protected static ?string $title = 'Documents';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected string $view = 'filament.pages.documents';
|
||||
|
||||
public string $select = 'jnl,number,thirdid,date';
|
||||
|
||||
public string $thirdId = '';
|
||||
|
||||
public string $detailJnl = '';
|
||||
|
||||
public string $detailNumber = '';
|
||||
|
||||
public array $data = [];
|
||||
|
||||
public array $detailData = [];
|
||||
|
||||
public ?array $metadata = null;
|
||||
|
||||
public ?string $errorMessage = null;
|
||||
|
||||
public function searchDocuments(): void
|
||||
{
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
|
||||
$params = array_filter([
|
||||
'select' => $this->select,
|
||||
'thirdid' => $this->thirdId,
|
||||
]);
|
||||
|
||||
$response = $service->documentList($params);
|
||||
|
||||
$this->data = $response['data'] ?? [];
|
||||
$this->metadata = $response['metadata'] ?? null;
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->data = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getDocumentDetail(): void
|
||||
{
|
||||
if (blank($this->detailJnl) || blank($this->detailNumber)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->documentDetail($this->detailJnl, $this->detailNumber);
|
||||
|
||||
$this->detailData = $response['data'] ?? [];
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->detailData = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user