-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added components to be able to display products
- Loading branch information
Showing
18 changed files
with
214 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php namespace Lbaig\Catalog\Components; | ||
|
||
use Cms\Classes\ComponentBase; | ||
use Lbaig\Catalog\Models\Category; | ||
|
||
class Breadcrumbs extends ComponentBase | ||
{ | ||
public function componentDetails() | ||
{ | ||
return [ | ||
'name' => 'Breadcrumbs Component', | ||
'description' => 'No description provided yet...' | ||
]; | ||
} | ||
|
||
public function defineProperties() | ||
{ | ||
return []; | ||
} | ||
|
||
public function get(Category $category = null) | ||
{ | ||
if ($category === null) { | ||
return []; | ||
} | ||
|
||
$result = [$category]; | ||
while ($category->parent !== null) { | ||
$result[] = $category->parent; | ||
$category = $category->parent; | ||
} | ||
\Log::info($result); | ||
|
||
return array_reverse($result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php namespace Lbaig\Catalog\Components; | ||
|
||
use Cms\Classes\ComponentBase; | ||
use Lbaig\Catalog\Models\Category; | ||
|
||
class CategoryItem extends ComponentBase | ||
{ | ||
public function componentDetails() | ||
{ | ||
return [ | ||
'name' => 'CategoryItem Component', | ||
'description' => 'No description provided yet...' | ||
]; | ||
} | ||
|
||
public function defineProperties() | ||
{ | ||
return [ | ||
'slug' => [ | ||
'title' => 'Category', | ||
'description' => 'Category of Products', | ||
'default' => '*', | ||
'type' => 'dropdown', | ||
] | ||
]; | ||
} | ||
|
||
|
||
public function get() | ||
{ | ||
$slug = $this->property('slug'); | ||
|
||
return Category::where('slug', $slug)->first(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php namespace Lbaig\Catalog\Components; | ||
|
||
use Cms\Classes\ComponentBase; | ||
use Lbaig\Catalog\Models\Category; | ||
|
||
|
||
class CategoryList extends ComponentBase | ||
{ | ||
public function componentDetails() | ||
{ | ||
return [ | ||
'name' => 'CategoryList Component', | ||
'description' => 'No description provided yet...' | ||
]; | ||
} | ||
|
||
public function defineProperties() | ||
{ | ||
return []; | ||
} | ||
|
||
public function getRootCategories() | ||
{ | ||
$categories = Category::active() | ||
->whereNull('parent_id') | ||
->get(); | ||
return $categories; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php namespace Lbaig\Catalog\Components; | ||
|
||
use Cms\Classes\ComponentBase; | ||
use Lbaig\Catalog\Models\Category; | ||
use Lbaig\Catalog\Models\Product; | ||
|
||
class ProductList extends ComponentBase | ||
{ | ||
public function componentDetails() | ||
{ | ||
return [ | ||
'name' => 'ProductList Component', | ||
'description' => 'No description provided yet...' | ||
]; | ||
} | ||
|
||
public function defineProperties() | ||
{ | ||
return []; | ||
} | ||
|
||
public function get(Category $category) | ||
{ | ||
// select all subcategories as well as category | ||
$subcategory_ids = Category::active() | ||
->where('nest_left', '>=', $category->nest_left) | ||
->where('nest_right', '<=', $category->nest_right) | ||
->pluck('id'); | ||
|
||
// select all products that belong to this category or lower | ||
$products = Product::active() | ||
->whereIn('category_id', $subcategory_ids) | ||
->get(); | ||
|
||
return $products; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This is the default markup for component Breadcrumbs</p> | ||
|
||
<small>You can delete this file if you want</small> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This is the default markup for component CategoryItem</p> | ||
|
||
<small>You can delete this file if you want</small> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This is the default markup for component CategoryList</p> | ||
|
||
<small>You can delete this file if you want</small> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>This is the default markup for component ProductList</p> | ||
|
||
<small>You can delete this file if you want</small> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div data-control="toolbar"> | ||
<a href="<?= Backend::url('lbaig/catalog/categories') ?>" class="btn btn-primary oc-icon-caret-left"> | ||
<?= e(trans('lbaig.catalog::lang.categories.return_to_categories')) ?> | ||
</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# =================================== | ||
# Reorder Behavior Config | ||
# =================================== | ||
|
||
# Reorder Title | ||
title: lbaig.catalog::lang.categories.reorder | ||
|
||
# Attribute name | ||
nameFrom: name | ||
|
||
# Model Class name | ||
modelClass: Lbaig\Catalog\Models\Category | ||
|
||
# Toolbar widget configuration | ||
toolbar: | ||
# Partial for toolbar buttons | ||
buttons: reorder_toolbar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?= $this->reorderRender() ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
'plugin' => [ | ||
'name' => 'Catalog', | ||
'description' => 'Custom catalog platform', | ||
], | ||
'categories' => [ | ||
'reorder' => 'Reorder', | ||
'return_to_categories' => 'Return to the category list', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,7 @@ columns: | |
name: | ||
label: Name | ||
type: text | ||
parent: | ||
lable: Category | ||
relation: parent | ||
select: name |