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\Categories;
|
||||||
use App\Repositories\Shop\Offers;
|
use App\Repositories\Shop\Offers;
|
||||||
use App\Repositories\Shop\Tags;
|
use App\Repositories\Shop\Tags;
|
||||||
|
use App\Repositories\Shop\TagGroups;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
@@ -24,11 +25,8 @@ class HomeController extends Controller
|
|||||||
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
||||||
// $data['offers'] = Offers::getLast()->toArray();
|
// $data['offers'] = Offers::getLast()->toArray();
|
||||||
$data['articles'] = Articles::getArticlesToSell();
|
$data['articles'] = Articles::getArticlesToSell();
|
||||||
$data['tags'] = Tags::getWithCountOffers();
|
// $data['tags'] = Tags::getWithCountOffers();
|
||||||
|
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||||
// $data['prices'] = $data['articles']['offers'][0]['tariff']['price_lists'][0]['price_list_values'][0];
|
|
||||||
// dump($data);
|
|
||||||
// exit;
|
|
||||||
return view('Shop.home', $data);
|
return view('Shop.home', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ class Articles
|
|||||||
public static function getArticlesToSell()
|
public static function getArticlesToSell()
|
||||||
{
|
{
|
||||||
$articles = self::getArticlesWithOffers();
|
$articles = self::getArticlesWithOffers();
|
||||||
// dump($articles->toArray());
|
|
||||||
// exit;
|
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
|
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
|
||||||
// dump($price_lists);
|
// dump($price_lists);
|
||||||
@@ -75,6 +73,8 @@ class Articles
|
|||||||
'image' => $article->image,
|
'image' => $article->image,
|
||||||
'product_type' => $article->product_type,
|
'product_type' => $article->product_type,
|
||||||
'product_id' => $article->product_id,
|
'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];
|
$prices = $price_lists[0]['price_list_values'][0];
|
||||||
$article_nature_name = strtolower($article->article_nature->name);
|
$article_nature_name = strtolower($article->article_nature->name);
|
||||||
|
|||||||
@@ -2,17 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use Yajra\DataTables\DataTables;
|
|
||||||
|
|
||||||
use App\Models\Shop\TagGroup;
|
use App\Models\Shop\TagGroup;
|
||||||
|
use App\Models\Shop\Tag;
|
||||||
|
|
||||||
class TagGroups
|
class TagGroups
|
||||||
{
|
{
|
||||||
public static function getDatatable()
|
|
||||||
{
|
|
||||||
$model = TagGroup::query();
|
|
||||||
return Datatables::of($model)->make(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getOptions()
|
public static function getOptions()
|
||||||
{
|
{
|
||||||
@@ -21,7 +15,17 @@ class TagGroups
|
|||||||
|
|
||||||
public static function getWithTagsAndCountOffers()
|
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()
|
public static function getTreeTags()
|
||||||
|
|||||||
@@ -2,18 +2,22 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<img src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" class="card-img-top" alt="...">
|
<img src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" class="card-img-top" alt="...">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<span class="card-title" style="font-weight: bold; color: green;">{{ $product_name }}</span>
|
<div class="row card-title">
|
||||||
<span class="float-right" style="font-size: 2em; color: red;">
|
<div class="col-10" style="font-weight: bold; color: green;">
|
||||||
|
<h2 style="font-size: 1.4em;">{{ $article['parent_name'] }}</h2>
|
||||||
|
{{ $article['product_name'] }}
|
||||||
|
</div>
|
||||||
|
<div class="col-2 p-0 text-right" style="font-size: 2em; color: red;">
|
||||||
<i class="fa fa-heart"></i>
|
<i class="fa fa-heart"></i>
|
||||||
</span>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p class="card-text">
|
|
||||||
<div class="row" style="color: green;">
|
<div class="row" style="color: green;">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
@if ($article['semences'] ?? false)
|
@if ($article['semences'] ?? false)
|
||||||
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['semences']['price'] ?? null }}</span> €<br>
|
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['semences']['price'] ?? null }}</span> €<br>
|
||||||
@else
|
@else
|
||||||
Indisponible
|
Indisponible<br>
|
||||||
@endif
|
@endif
|
||||||
Semence
|
Semence
|
||||||
</div>
|
</div>
|
||||||
@@ -21,12 +25,11 @@
|
|||||||
@if ($article['plants'] ?? false)
|
@if ($article['plants'] ?? false)
|
||||||
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['plants']['price'] }}</span> €<br>
|
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['plants']['price'] }}</span> €<br>
|
||||||
@else
|
@else
|
||||||
Indisponible
|
Indisponible<br>
|
||||||
@endif
|
@endif
|
||||||
Plant
|
Plant
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,2 +1,12 @@
|
|||||||
@foreach ($tags as $tag)
|
@foreach ($tags as $group)
|
||||||
|
<h5>{{ $group['name'] }}</h5>
|
||||||
|
@foreach ($group['tags'] as $tag)
|
||||||
|
<div>
|
||||||
|
@include('components.form.checkbox', [
|
||||||
|
'name' => 'tag[]',
|
||||||
|
'val' => $tag['id'],
|
||||||
|
])
|
||||||
|
{{ $tag['name'] }} ({{ $tag['count'] }})
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
|
@include('Shop.Tags.partials.filter')
|
||||||
</div>
|
</div>
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
@if ($display_by_rows ?? false)
|
@if ($display_by_rows ?? false)
|
||||||
|
|||||||
Reference in New Issue
Block a user