Author: Gustavo Ocanto (gustavoocanto@gmail.com)
Example #1
0
 public static function categoriesDropDownFormat($array, &$outPut)
 {
     foreach ($array as $row) {
         /**
          * $level
          * Contains the category tree
          * @var [type]
          */
         $level = categoriesHelper::level($array, $row['category_id']);
         $s = '';
         for ($i = 0; $i < $level; $i++) {
             $s .= '&nbsp;&nbsp;&nbsp;';
         }
         $icon = 2;
         if ($level % 3 == 0) {
             $icon = 0;
         } elseif ($level % 2 == 0) {
             $icon = 1;
         }
         $indentation = ['&#9679;', '&#8226;', '&ordm;'][$icon];
         $outPut[$row['id']] = $s . $indentation . '&nbsp;' . $row['name'];
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $categoriesHelper = new categoriesHelper();
     $data = Category::where('id', '<>', $id)->mothers()->orderBy('type')->get()->toArray();
     $data = $categoriesHelper->separateTypesCategories($data);
     $panel = ['left' => ['width' => '2'], 'center' => ['width' => '10']];
     $storeCategories = ['' => trans('categories.no_father')];
     $groupCategories = ['' => trans('categories.no_father')];
     foreach ($data['group'] as $row) {
         $groupCategories[$row['id']] = $row['name'];
     }
     foreach ($data['store'] as $row) {
         $storeCategories[$row['id']] = $row['name'];
     }
     return view('categories.update', ['categories' => $data, 'category' => Category::find($id), 'panel' => $panel, 'groupCategories' => $groupCategories, 'storeCategories' => $storeCategories]);
 }
Example #3
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $product = Product::find(-50);
     $features = ProductDetail::all()->toArray();
     $arrayCategories = Category::actives()->lightSelection()->get()->toArray();
     $categories = ["" => trans("product.controller.select_category")];
     $condition = ['new' => trans('product.controller.new'), 'refurbished' => trans('product.controller.refurbished'), 'used' => trans('product.controller.used')];
     $typesProduct = ['item' => trans("product.controller.item"), 'key' => trans("product.globals.digital_item") . ' ' . trans("product.globals.key")];
     $typeItem = 'item';
     foreach ($arrayCategories as $row) {
         #just a little bit of pre format in categories dropdown
         $level = categoriesHelper::level($arrayCategories, $row['category_id']);
         $s = '';
         for ($i = 0; $i < $level; $i++) {
             $s .= '&nbsp;&nbsp;&nbsp;';
         }
         $icon = 2;
         if ($level % 3 == 0) {
             $icon = 0;
         } elseif ($level % 2 == 0) {
             $icon = 1;
         }
         $indentation = ['&#9679;', '&#8226;', '&ordm;'][$icon];
         #end pre format
         $categories[$row['id']] = $s . $indentation . '&nbsp;' . $row['name'];
     }
     $disabled = '';
     $edit = false;
     $panel = $this->panel;
     $oldFeatures = ProductDetail::oldFeatures([]);
     $productsDetails = new featuresHelper();
     return view('products.form', compact('product', 'panel', 'features', 'categories', 'condition', 'typeItem', 'typesProduct', 'disabled', 'edit', 'oldFeatures', 'productsDetails'));
 }