@php $title = $data->title; $items = []; switch ($$data->view_type) { case 'categories': if (count($categories = $helper->getProductCategories(['id' => $data->categories ?? [0]]))) { foreach ($categories as $cate) { $items[] = [ 'sub_title' => null, 'title' => $cate->name, 'image' => $cate->getFeaturedImage(), 'url' => $cate->getViewUrl(), ]; } } break; case 'posts': $args = [ '@limit' => $data->post_number ? $data->post_number : 5, '@sort' => $data->sorttype ? $data->sorttype : 1, ]; $title = null; if ($data->dynamic_id && ($dynamic = $helper->getDynamic(['id' => $data->dynamic_id]))) { $args['dynamic_id'] = $data->dynamic_id; $title = $dynamic->name; } if ($data->category_id && ($category = $helper->getPostCategory(['id' => $data->category_id]))) { $args['@category'] = $data->category_id; if (!$title) { $title = $category->name; } } if ($data->content_type && $data->content_type != 'all') { $args['content_type'] = $data->content_type; } $args['trashed_status'] = 0; if (count($posts = $helper->getPosts($args))) { foreach ($posts as $post) { $item[] = [ 'sub_title' => $post->category ? $post->category->name : null, 'title' => $post->title, 'image' => $cate->getFeaturedImage(), 'url' => $post->getViewUrl(), ]; } } break; default: if ($children && count($children)) { $comps = $children->getComponents(); if (count($comps)) { foreach ($comps as $c) { $cd = $c->data; $items[] = [ 'sub_title' => $cd->sub_title, 'title' => $cd->title, 'image' => $cd->image(), 'url' => $cd->title, ]; } } } break; } @endphp