<?php

namespace App\Http\Controllers\Shop;

use App\Http\Controllers\Controller;
use App\Repositories\Shop\Categories;
use App\Repositories\Shop\Shelves;
use Illuminate\Http\Request;

class CategoryController extends Controller
{
    public function show(Request $request, $categoryId, $articleNatureId = false)
    {
        $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);

        return view('Shop.Shelves.shelve', $data);
    }

    public function getTree()
    {
        return response()->json(Categories::getTree());
    }
}
