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 ProductService extends InsForgeTableService
|
||||
{
|
||||
protected function table(): string
|
||||
{
|
||||
return 'products';
|
||||
}
|
||||
|
||||
protected function searchableColumns(): array
|
||||
{
|
||||
return ['name', 'code'];
|
||||
}
|
||||
|
||||
protected function sortableColumns(): array
|
||||
{
|
||||
return ['code', 'name', 'created_at', 'stock_minimum', 'cost_price'];
|
||||
}
|
||||
|
||||
public function nextCode(): string
|
||||
{
|
||||
$last = $this->client->listRecords($this->table(), [
|
||||
'order' => 'code.desc.nullslast',
|
||||
'limit' => 1,
|
||||
'select' => 'code',
|
||||
])[0]['code'] ?? null;
|
||||
|
||||
preg_match('/(\d+)$/', (string) $last, $matches);
|
||||
|
||||
return sprintf('BERAS-%03d', ((int) ($matches[1] ?? 0)) + 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user