46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\InsForge\InsForgeTableService;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
class StockMovementService extends InsForgeTableService
|
|
{
|
|
public const TYPES = ['restock', 'adjustment', 'order_out'];
|
|
|
|
protected function table(): string
|
|
{
|
|
return 'stock_movements';
|
|
}
|
|
|
|
protected function select(): string
|
|
{
|
|
return '*,products(code,name)';
|
|
}
|
|
|
|
protected function searchableColumns(): array
|
|
{
|
|
return ['notes', 'type'];
|
|
}
|
|
|
|
protected function sortableColumns(): array
|
|
{
|
|
return ['created_at', 'quantity', 'type'];
|
|
}
|
|
|
|
/** @param array<string, mixed> $filters */
|
|
public function paginate(
|
|
?string $search = null,
|
|
?string $sortColumn = null,
|
|
?string $sortDirection = null,
|
|
int $page = 1,
|
|
int $perPage = 25,
|
|
array $filters = [],
|
|
): LengthAwarePaginator {
|
|
$extra = array_intersect_key($filters, array_flip(['type', 'product_id']));
|
|
|
|
return parent::paginate($search, $sortColumn, $sortDirection, $page, $perPage, $extra);
|
|
}
|
|
}
|