feat: phase 2 — master data (products, customers, drivers) via InsForge-backed Filament pages
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\InsForge\InsForgeTableService;
|
||||
|
||||
class CustomerService extends InsForgeTableService
|
||||
{
|
||||
protected function table(): string
|
||||
{
|
||||
return 'customers';
|
||||
}
|
||||
|
||||
protected function searchableColumns(): array
|
||||
{
|
||||
return ['name', 'customer_code', 'phone'];
|
||||
}
|
||||
|
||||
protected function sortableColumns(): array
|
||||
{
|
||||
return ['customer_code', 'name', 'created_at'];
|
||||
}
|
||||
|
||||
public function nextCode(): string
|
||||
{
|
||||
$last = $this->client->listRecords($this->table(), [
|
||||
'order' => 'customer_code.desc.nullslast',
|
||||
'limit' => 1,
|
||||
'select' => 'customer_code',
|
||||
])[0]['customer_code'] ?? null;
|
||||
|
||||
preg_match('/(\d+)$/', (string) $last, $matches);
|
||||
|
||||
return sprintf('CUST-%04d', ((int) ($matches[1] ?? 0)) + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user