Skip to content

Commit

Permalink
Fix error language categories
Browse files Browse the repository at this point in the history
  • Loading branch information
lanhktc committed Jun 11, 2021
1 parent d705c3e commit d4ae296
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Admin/Controllers/AdminProductController.php
Expand Up @@ -29,7 +29,6 @@ class AdminProductController extends RootAdminController
public $attributeGroup;
public $listWeight;
public $listLength;
public $categories;

public function __construct()
{
Expand All @@ -44,8 +43,6 @@ public function __construct()
SC_PRODUCT_GROUP => sc_language_render('product.kind_group'),
];
$this->properties = (new ShopProductProperty)->pluck('name', 'code')->toArray();
$this->categories = (new AdminCategory)->getTreeCategoriesAdmin();

}

public function index()
Expand Down Expand Up @@ -186,8 +183,9 @@ public function index()

//Search with category
$optionCategory = '';
if ($this->categories) {
foreach ($this->categories as $k => $v) {
$categories = (new AdminCategory)->getTreeCategoriesAdmin();
if ($categories) {
foreach ($categories as $k => $v) {
$optionCategory .= "<option value='{$k}' ".(($category_id == $k) ? 'selected' : '').">{$v}</option>";
}
}
Expand Down Expand Up @@ -218,6 +216,7 @@ public function index()
*/
public function create()
{
$categories = (new AdminCategory)->getTreeCategoriesAdmin();
// html add more images
$htmlMoreImage = '<div class="input-group"><input type="text" id="id_sub_image" name="sub_image[]" value="image_value" class="form-control rounded-0 input-sm sub_image" placeholder="" /><span class="input-group-btn"><a data-input="id_sub_image" data-preview="preview_sub_image" data-type="product" class="btn btn-primary lfm"><i class="fa fa-picture-o"></i> Choose</a></span></div><div id="preview_sub_image" class="img_holder"></div>';
//end add more images
Expand All @@ -232,7 +231,7 @@ public function create()
'title_description' => sc_language_render('product.admin.add_new_des'),
'icon' => 'fa fa-plus',
'languages' => $this->languages,
'categories' => $this->categories,
'categories' => $categories,
'brands' => (new ShopBrand)->getListAll(),
'suppliers' => (new ShopSupplier)->getListAll(),
'taxs' => (new ShopTax)->getListAll(),
Expand All @@ -256,6 +255,8 @@ public function create()
*/
public function createProductBuild()
{
$categories = (new AdminCategory)->getTreeCategoriesAdmin();

$listProductSingle = (new AdminProduct)->getProductSelectAdmin(['kind' => [0]]);

// html select product build
Expand Down Expand Up @@ -284,7 +285,7 @@ public function createProductBuild()
'title_description' => sc_language_render('product.admin.add_new_des'),
'icon' => 'fa fa-plus',
'languages' => $this->languages,
'categories' => $this->categories,
'categories' => $categories,
'brands' => (new ShopBrand)->getListAll(),
'suppliers' => (new ShopSupplier)->getListAll(),
'taxs' => (new ShopTax)->getListAll(),
Expand All @@ -310,6 +311,8 @@ public function createProductBuild()
*/
public function createProductGroup()
{
$categories = (new AdminCategory)->getTreeCategoriesAdmin();

$listProductSingle = (new AdminProduct)->getProductSelectAdmin(['kind' => [0]]);

// html select product group
Expand All @@ -330,7 +333,7 @@ public function createProductGroup()
'title_description' => sc_language_render('product.admin.add_new_des'),
'icon' => 'fa fa-plus',
'languages' => $this->languages,
'categories' => $this->categories,
'categories' => $categories,
'brands' => (new ShopBrand)->getListAll(),
'suppliers' => (new ShopSupplier)->getListAll(),
'taxs' => (new ShopTax)->getListAll(),
Expand Down Expand Up @@ -617,6 +620,7 @@ public function postCreate()
public function edit($id)
{
$product = (new AdminProduct)->getProductAdmin($id);
$categories = (new AdminCategory)->getTreeCategoriesAdmin();

if ($product === null) {
return redirect()->route('admin.data_not_found')->with(['url' => url()->full()]);
Expand Down Expand Up @@ -658,7 +662,7 @@ public function edit($id)
'icon' => 'fa fa-edit',
'languages' => $this->languages,
'product' => $product,
'categories' => $this->categories,
'categories' => $categories,
'brands' => (new ShopBrand)->getListAll(),
'suppliers' => (new ShopSupplier)->getListAll(),
'taxs' => (new ShopTax)->getListAll(),
Expand Down

0 comments on commit d4ae296

Please sign in to comment.