added zarbox list

This commit is contained in:
2026-06-09 19:58:48 +03:30
parent b5c2b2be72
commit ae9ba34ca8
3 changed files with 41 additions and 0 deletions
@@ -59,6 +59,18 @@ class PriceController extends Controller
]);
}
public function zaarboxProducts(ZaarboxPriceService $zaarboxPriceService)
{
return response()->json([
'code' => 0,
'message' => 'عملیات با موفقیت انجام شد.',
'data' => [
'items' => $zaarboxPriceService->listProductOptions(),
'api_url' => $zaarboxPriceService->apiUrl(),
],
]);
}
public function table(Request $request){
$records = Price::with(['user']);
TableEngine::create($records, $request->all())
+28
View File
@@ -167,6 +167,34 @@ class ZaarboxPriceService
}
}
/**
* @return array<int, array{key: string, name: string, id: string, category: string, active: bool}>
*/
public function listProductOptions(): array
{
$prices = $this->fetchPriceList();
if ($prices === null) {
return [];
}
return collect($prices)
->map(function ($row) {
$row = is_array($row) ? $row : (array) $row;
return [
'key' => trim((string) ($row['key'] ?? '')),
'name' => trim((string) ($row['name'] ?? '')),
'id' => trim((string) ($row['id'] ?? '')),
'category' => trim((string) ($row['category'] ?? '')),
'active' => (bool) ($row['active'] ?? false),
];
})
->filter(fn (array $row) => $row['key'] !== '')
->sortBy('name', SORT_NATURAL | SORT_FLAG_CASE)
->values()
->all();
}
/**
* @return array{order_price: int, raw: array<string, mixed>|null}
*/
+1
View File
@@ -111,6 +111,7 @@ Route::middleware('auth:user')->group(function (){
Route::post('price/table', [PriceController::class, 'table']);
Route::post('prices', [PriceController::class, 'priceData']);
Route::post('prices/chart', [PriceController::class, 'chartPrices']);
Route::get('zaarbox/products', [PriceController::class, 'zaarboxProducts']);
Route::post('finance', [FinanceController::class, 'fall']);