This commit is contained in:
Hankin 2026-05-26 10:28:54 +08:00
parent 04ab1ec6a9
commit fc7c6757f4

View File

@ -296,16 +296,16 @@ class GuideController extends Controller
$scheme[$key]['config'] = json_decode($config, true);
}
}
$foods = Food::where('type', Food::TYPE_FOOD)->select('id', 'name', 'icon', 'unit', 'price', 'stock as num', 'type', 'config')->orderByDesc('id')->get()?->toArray();
foreach ($foods as $k => $v) {
if (empty($v['config'])) {
continue;
}
$foods[$k]['config'] = json_decode($v['config'], true);
}
// 合并 $scheme 和 $foods 数组
$result = array_merge($scheme, $foods);
return $this->success('ok', $result);
// $foods = Food::where('type', Food::TYPE_FOOD)->select('id', 'name', 'icon', 'unit', 'price', 'stock as num', 'type', 'config')->orderByDesc('id')->get()?->toArray();
// foreach ($foods as $k => $v) {
// if (empty($v['config'])) {
// continue;
// }
// $foods[$k]['config'] = json_decode($v['config'], true);
// }
// // 合并 $scheme 和 $foods 数组
// $result = array_merge($scheme, $foods);
return $this->success('ok', $scheme);
} catch (\Exception $e) {
AddErrorLog::dispatch('getOrderFood file:' . $e->getFile() . ' line:' . $e->getLine() . ' message:' . $e->getMessage())->onQueue('health');
return $this->failure('获取失败');