Add the touch-screen machine console
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -58,6 +58,14 @@ interface StockQueries
|
||||
*/
|
||||
public function taskSuggestions(int $taskId): array;
|
||||
|
||||
/**
|
||||
* Items used most often on the machine in the last 90 days, then the
|
||||
* ones used most recently, for the machine console (spec 19.6).
|
||||
*
|
||||
* @return array{frequent: list<int>, recent: list<int>}
|
||||
*/
|
||||
public function machineFavourites(int $machineId, int $limit = 8): array;
|
||||
|
||||
/**
|
||||
* The private-disk path of the item's image or its thumbnail.
|
||||
*/
|
||||
|
||||
+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