change display on categories
This commit is contained in:
@@ -11,9 +11,11 @@ use App\Repositories\Shop\Offers;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
|
||||
use App\Datatables\Shop\CategoriesDataTable;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
public function index(CategoriesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Categories.list');
|
||||
}
|
||||
@@ -23,6 +25,7 @@ class CategoryController extends Controller
|
||||
$data = self::init();
|
||||
$data['display_by_rows'] = $by_rows;
|
||||
$data['category'] = Categories::getFull($category_id);
|
||||
$data['breadcrumb'] = Categories::getAncestorsByCategory($category_id);
|
||||
$data['tags_selected'] = request()->input('tags') ?? [];
|
||||
$data['articles'] = Articles::getArticlesToSell([
|
||||
'category_id' => $category_id,
|
||||
|
||||
@@ -8,6 +8,21 @@ use App\Repositories\Core\Categories as CategoryTrees;
|
||||
|
||||
class Categories
|
||||
{
|
||||
public static function getAncestorsByArticle($id)
|
||||
{
|
||||
$category = Articles::get($id)->categories()->first();
|
||||
$ancestors = self::getAncestorsByCategory($category->id);
|
||||
$ancestors[] = $category->toArray();
|
||||
return $ancestors;
|
||||
}
|
||||
|
||||
public static function getAncestorsByCategory($id)
|
||||
{
|
||||
$category = self::get($id);
|
||||
$ancestors = $category->getAncestors()->toArray();
|
||||
unset($ancestors[0]);
|
||||
return $ancestors;
|
||||
}
|
||||
|
||||
public static function getByHomepage()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user