| xqd
@@ -45,9 +45,12 @@ class ProductController extends Controller
|
|
|
}
|
|
|
$list = $query->paginate();
|
|
|
foreach ($list as $key => $item) {
|
|
|
- $cat = AlbumCatModel::where('id', $item->cat_id)->first();dd($cat);
|
|
|
- $catParent = AlbumCatModel::where('id', $cat->parent_id)->first();
|
|
|
- $item->cat_name = ($catParent->name ?? '') . '>' . $cat->name;
|
|
|
+ $cat = AlbumCatModel::where('id', $item->cat_id)->first();
|
|
|
+ if ($cat) {
|
|
|
+ $catParent = AlbumCatModel::where('id', $cat->parent_id)->first();
|
|
|
+ }
|
|
|
+
|
|
|
+ $item->cat_name = ($catParent->name ?? '暂无') . '>' . ($cat->name ?? '暂无');
|
|
|
$upload_img = json_decode($item->upload_img);
|
|
|
$attr = json_decode($item->attr);
|
|
|
$detail = json_decode($item->detail);
|