我正在尝试使用存储在数据库中的图像编写一个API作为blob我没有得到JSON的响应,但得到的结果是标准对象或数组。code
{
$menu_cat_data = [];
$main_categories = DB::table('categories')->select('categories.id as menu_category_id', 'categories.name as menu_category_name',
'categories.image as menu_category_image')
->join('products', 'categories.id', '=', 'products.CATEGORY')
->where('categories.SITEGUID', '=', $id)
->distinct()
->get();
if (count($main_categories) > 0) {
$cnt = 0;
$menu_cat_data = [];
foreach ($main_categories as $main_categorys) {
$main_categorys['menu_category_image'];
$menu_cat_data['menu'][$main_categorys- >menu_category_id] = (array) $main_categorys;
$products = DB::table('products')->select('products.id as menu_item_id', 'products.name as menu_item_name',
'products.PRICESELL as rate', 'products.image as menu_product_image')
->where('products.SITEGUID', '=', $id)
->where('products.category', '=', $main_categorys->menu_category_id)
->join('categories', 'products.category', '=', 'categories.id')
->distinct()
->get();
if (count($products) > 0) {
foreach ($products as $product) {
$menu_cat_data['menu'][$main_categorys->menu_category_id]['items'][$product->menu_item_id] = (array) $product;
}
}
}
}
$response = json_encode($menu_cat_data);
print_r($response);
}