fix basket
This commit is contained in:
@@ -2,56 +2,22 @@
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Datatables\Shop\CategoriesDataTable;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Shop\ArticleNatures;
|
||||
use App\Repositories\Shop\Articles;
|
||||
use App\Repositories\Shop\Categories;
|
||||
use App\Repositories\Shop\Shelves;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
public function index(CategoriesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Categories.list');
|
||||
}
|
||||
|
||||
public function show(Request $request, $categoryId, $articleNatureId = false)
|
||||
{
|
||||
$articleNatures = Articles::getArticleNaturesWithOffers([
|
||||
'category_id' => $categoryId,
|
||||
]);
|
||||
|
||||
if ($articleNatureId) {
|
||||
$productType = ArticleNatures::getProductType($articleNatureId);
|
||||
} else {
|
||||
$articleNature = $request->input('article_nature');
|
||||
if (! $articleNature) {
|
||||
if (count($articleNatures)) {
|
||||
$articleNature = $articleNatures[0];
|
||||
}
|
||||
}
|
||||
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
|
||||
$articleNatureId = ArticleNatures::getIdBySlug($articleNature);
|
||||
}
|
||||
$data = [
|
||||
'category' => Categories::getFull($categoryId),
|
||||
'breadcrumb' => Categories::getAncestorsByCategory($categoryId),
|
||||
'display_by_rows' => $request->input('display_by_rows') ?? false,
|
||||
'product_type' => $productType,
|
||||
'article_nature' => $articleNature,
|
||||
'article_natures' => $articleNatures ?? [],
|
||||
'product_types' => $productTypes ?? [],
|
||||
'tags_selected' => $request->input('tags') ?? [],
|
||||
'articles' => Articles::getArticlesToSell([
|
||||
'category_id' => $categoryId,
|
||||
'tags' => $request->input('tags') ?? [],
|
||||
'product_type' => $productType ?? false,
|
||||
'article_nature_id' => $articleNatureId ?? false,
|
||||
]),
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
|
||||
];
|
||||
$articleNature = $request->input('article_nature') ?? false;
|
||||
$displayByRows = $request->input('display_by_rows') ?? false;
|
||||
$tags = $request->input('tags') ?? [];
|
||||
$data = Shelves::getOffersByCategoryAndNature($categoryId, $articleNatureId, $tags, $articleNature, $displayByRows);
|
||||
|
||||
// dump($data);
|
||||
// exit;
|
||||
|
||||
50
app/Repositories/Shop/Shelves.php
Normal file
50
app/Repositories/Shop/Shelves.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Category;
|
||||
use App\Repositories\Core\Categories as CategoryTrees;
|
||||
use App\Repositories\Core\Tag;
|
||||
|
||||
class Shelves
|
||||
{
|
||||
public static function getOffersByCategoryAndNature($categoryId, $articleNatureId = false, $tags = [], $articleNature = false, $displayByRows = false)
|
||||
{
|
||||
$productTypes = Articles::getProductTypesWithOffers([
|
||||
'category_id' => $categoryId,
|
||||
]);
|
||||
|
||||
$articleNatures = Articles::getArticleNaturesWithOffers([
|
||||
'category_id' => $categoryId,
|
||||
]);
|
||||
|
||||
if ($articleNatureId) {
|
||||
$productType = ArticleNatures::getProductType($articleNatureId);
|
||||
} else {
|
||||
if (! $articleNature) {
|
||||
if (count($articleNatures)) {
|
||||
$articleNature = $articleNatures[0];
|
||||
}
|
||||
}
|
||||
$productType = ArticleNatures::getProductTypeBySlug($articleNature);
|
||||
$articleNatureId = ArticleNatures::getIdBySlug($articleNature);
|
||||
}
|
||||
return [
|
||||
'category' => Categories::getFull($categoryId),
|
||||
'breadcrumb' => Categories::getAncestorsByCategory($categoryId),
|
||||
'display_by_rows' => $displayByRows,
|
||||
'product_type' => $productType,
|
||||
'article_nature' => $articleNature,
|
||||
'article_natures' => $articleNatures ?? [],
|
||||
'product_types' => $productTypes ?? [],
|
||||
'tags_selected' => $tags,
|
||||
'articles' => Articles::getArticlesToSell([
|
||||
'category_id' => $categoryId,
|
||||
'tags' => $tags,
|
||||
'product_type' => $productType ?? false,
|
||||
'article_nature_id' => $articleNatureId ?? false,
|
||||
]),
|
||||
'tags' => TagGroups::getWithTagsAndCountOffers($categoryId),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user