This commit is contained in:
Ludovic CANDELLIER
2022-01-19 22:43:32 +01:00
parent b3f2aa36be
commit efff4f0341
7 changed files with 43 additions and 10 deletions

View File

@@ -18,5 +18,4 @@ class ArticleController extends Controller
// exit; // exit;
return view('Shop.Articles.show', $data); return view('Shop.Articles.show', $data);
} }
} }

View File

@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
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 CategoryController extends Controller class CategoryController extends Controller
{ {
@@ -22,6 +23,7 @@ class CategoryController extends Controller
$data['category'] = Categories::getFull($id); $data['category'] = Categories::getFull($id);
$data['offers'] = Offers::getByCategoryWithTags($id); $data['offers'] = Offers::getByCategoryWithTags($id);
$data['tags'] = Tags::getWithCountOffers(); $data['tags'] = Tags::getWithCountOffers();
$data['tags2'] = TagGroups::getWithTagsAndCountOffers();
dump($data); dump($data);
exit; exit;
return view('Shop.shelve', $data); return view('Shop.shelve', $data);

View File

@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
use App\Repositories\Shop\Articles; 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;
class HomeController extends Controller class HomeController extends Controller
{ {
@@ -23,6 +24,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['prices'] = $data['articles']['offers'][0]['tariff']['price_lists'][0]['price_list_values'][0]; // $data['prices'] = $data['articles']['offers'][0]['tariff']['price_lists'][0]['price_list_values'][0];
// dump($data); // dump($data);
// exit; // exit;

View File

@@ -19,6 +19,11 @@ class TagGroups
return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray(); return TagGroup::get()->SortBy('name')->pluck('name', 'id')->toArray();
} }
public static function getWithTagsAndCountOffers()
{
return TagGroup::with('tags')->withCount(['tags.articles'])->get()->toArray();
}
public static function getTreeTags() public static function getTreeTags()
{ {
$items = TagGroup::with('tags')->get(); $items = TagGroup::with('tags')->get();

View File

@@ -26,8 +26,24 @@
@component('components.card', [ @component('components.card', [
'title' => 'Plant', 'title' => 'Plant',
'class' => 'mb-3',
])
@include('components.form.button', [
'class' => 'btn-success basket plants',
'txt' => 'Ajouter au panier',
]) ])
@endcomponent @endcomponent
@component('components.card', [
'title' => 'Légume',
'class' => 'mb-3',
])
@include('components.form.button', [
'class' => 'btn-success basket legumes',
'txt' => 'Ajouter au panier',
])
@endcomponent
</div> </div>
</div> </div>
@endsection @endsection

View File

@@ -0,0 +1,2 @@
@foreach ($tags as $tag)
@endforeach

View File

@@ -3,9 +3,15 @@
]) ])
@section('content') @section('content')
<div class="row">
<div class="col-2">
</div>
<div class="col-10">
@if ($display_by_rows ?? false) @if ($display_by_rows ?? false)
@include('Shop.layout.partials.category_articles_rows') @include('Shop.layout.partials.category_articles_rows')
@else @else
@include('Shop.layout.partials.category_articles') @include('Shop.layout.partials.category_articles')
@endif @endif
</div>
</div>
@endsection @endsection