Add the touch-screen machine console
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
+16
@@ -130,6 +130,22 @@ class EloquentStockQueries implements StockQueries
|
||||
->all();
|
||||
}
|
||||
|
||||
public function machineFavourites(int $machineId, int $limit = 8): array
|
||||
{
|
||||
$uses = StockMovementModel::query()
|
||||
->where('machine_id', $machineId)
|
||||
->whereIn('kind', ['consumption', 'write_off'])
|
||||
->whereNull('reverses_movement_id')
|
||||
->where('recorded_at', '>=', now()->subDays(90))
|
||||
->orderByDesc('id')
|
||||
->get(['id', 'stock_item_id']);
|
||||
|
||||
$frequent = $uses->countBy('stock_item_id')->sortDesc()->keys()->take($limit)->map(fn ($id): int => (int) $id)->values()->all();
|
||||
$recent = $uses->pluck('stock_item_id')->unique()->take($limit)->map(fn ($id): int => (int) $id)->values()->all();
|
||||
|
||||
return ['frequent' => $frequent, 'recent' => $recent];
|
||||
}
|
||||
|
||||
public function imagePathOf(int $itemId, bool $thumbnail): ?string
|
||||
{
|
||||
$model = StockItemModel::query()->find($itemId, ['id', 'image_path', 'thumbnail_path']);
|
||||
|
||||
Reference in New Issue
Block a user