store
This commit is contained in:
@@ -71,6 +71,33 @@ class PriceController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/** لیست مرجع قیمت برای ادمین قدیمی (ghatreh_admin) — GET /admin/p */
|
||||
public function methodPrices(ZaarboxPriceService $zaarboxPriceService)
|
||||
{
|
||||
$prices = $zaarboxPriceService->cachedPriceList(false);
|
||||
if ($prices === null) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
$items = collect($prices)
|
||||
->map(function ($row) use ($zaarboxPriceService) {
|
||||
$row = is_array($row) ? $row : (array) $row;
|
||||
$normalized = $zaarboxPriceService->normalizeFeedRow($row);
|
||||
|
||||
return [
|
||||
'id' => trim((string) ($row['id'] ?? $row['key'] ?? '')),
|
||||
'key' => trim((string) ($row['key'] ?? '')),
|
||||
'name' => trim((string) ($row['name'] ?? '')),
|
||||
'price' => (int) round((float) ($normalized['price'] ?? 0)),
|
||||
'profit' => (int) round((float) ($normalized['profit'] ?? 0)),
|
||||
];
|
||||
})
|
||||
->filter(fn (array $row) => $row['name'] !== '')
|
||||
->values();
|
||||
|
||||
return response()->json($items);
|
||||
}
|
||||
|
||||
public function table(Request $request){
|
||||
$records = Price::with(['user']);
|
||||
TableEngine::create($records, $request->all())
|
||||
|
||||
Reference in New Issue
Block a user