【发布时间】:2021-05-07 12:51:27
【问题描述】:
public function goesWellWith(Request $request)
{
$seo_url = $request->seo_url;
$product = $this->product->getByAny('seo_url',$request->seo_url)->first();
$categories = $this->product->getProductCategories($product->id);
$category_ids = [];
$products = [];
if(count($categories) > 0){
$category_ids = array_column($categories, 'term_id');
}
if(count($category_ids) > 0){
$get_fillter_product = $this->product->getProductByFilter([
'recommended' => "on"
],$category_ids);
foreach($get_fillter_product as $single_product){
$categoryProductList = [
'title' => $single_product->title,
'sub_title' => $single_product->sub_title,
'first_image' => $single_product->first_image?$single_product->first_image->full_size_directory: null,
'second_image' => $single_product->second_image?$single_product->second_image->full_size_directory: null,
'seo_url' => $single_product->seo_url
];
$category_ids [] = $categoryProductList;
}
}
return response()->json(compact('category_ids'));
}
//
-
列表项
当我在失眠中点击 url 来检查时,我得到了这个 ErrorException array_column() 期望参数 1 是数组,给定对象//
我在这行代码中遇到了错误
if(count($categories) > 0){
$category_ids = array_column($categories, 'term_id');
}
【问题讨论】:
标签: laravel