Display filters, and fix css for article
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Repositories\Shop\Articles;
|
||||
use App\Repositories\Shop\Categories;
|
||||
use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -24,11 +25,8 @@ class HomeController extends Controller
|
||||
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
||||
// $data['offers'] = Offers::getLast()->toArray();
|
||||
$data['articles'] = Articles::getArticlesToSell();
|
||||
$data['tags'] = Tags::getWithCountOffers();
|
||||
|
||||
// $data['prices'] = $data['articles']['offers'][0]['tariff']['price_lists'][0]['price_list_values'][0];
|
||||
// dump($data);
|
||||
// exit;
|
||||
// $data['tags'] = Tags::getWithCountOffers();
|
||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||
return view('Shop.home', $data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,6 @@ class Articles
|
||||
public static function getArticlesToSell()
|
||||
{
|
||||
$articles = self::getArticlesWithOffers();
|
||||
// dump($articles->toArray());
|
||||
// exit;
|
||||
foreach ($articles as $article) {
|
||||
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
|
||||
// dump($price_lists);
|
||||
@@ -75,6 +73,8 @@ class Articles
|
||||
'image' => $article->image,
|
||||
'product_type' => $article->product_type,
|
||||
'product_id' => $article->product_id,
|
||||
'product_name' => $article->product->name,
|
||||
'parent_name' => trim(str_replace($article->product->name, '', $article->name)),
|
||||
];
|
||||
$prices = $price_lists[0]['price_list_values'][0];
|
||||
$article_nature_name = strtolower($article->article_nature->name);
|
||||
|
||||
@@ -2,17 +2,11 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\TagGroup;
|
||||
use App\Models\Shop\Tag;
|
||||
|
||||
class TagGroups
|
||||
{
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = TagGroup::query();
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
@@ -21,7 +15,17 @@ class TagGroups
|
||||
|
||||
public static function getWithTagsAndCountOffers()
|
||||
{
|
||||
return TagGroup::with('tags')->withCount(['tags.articles'])->get()->toArray();
|
||||
$tags = Tag::withCount(['articles'])->get()->toArray();
|
||||
$tag_groups = TagGroup::pluck('name','id')->toArray();
|
||||
foreach ($tags as $tag) {
|
||||
$data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']];
|
||||
$data[$tag['tag_group_id']]['tags'][] = [
|
||||
'id' => $tag['id'],
|
||||
'name' => $tag['name'],
|
||||
'count' => $tag['articles_count'],
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getTreeTags()
|
||||
|
||||
Reference in New Issue
Block a user