public function getEdit($id)
 {
     // Find the product using the user id
     $product = Product::find($id);
     // No such id
     if ($product == null) {
         return \View::make('redminportal::pages/404');
     }
     $categories = array();
     foreach (Category::all() as $category) {
         $categories[$category->id] = $category->name;
     }
     $tagString = "";
     foreach ($product->tags as $tag) {
         if (!empty($tagString)) {
             $tagString .= ",";
         }
         $tagString .= $tag->name;
     }
     if (empty($product->options)) {
         $product_cn = (object) array('name' => $product->name, 'short_description' => $product->short_description, 'long_description' => $product->long_description);
     } else {
         $product_cn = json_decode($product->options);
     }
     return View::make('redminportal::products/edit')->with('product', $product)->with('product_cn', $product_cn)->with('imageUrl', 'assets/img/products/')->with('categories', $categories)->with('tagString', $tagString);
 }
 public function testDestroy()
 {
     $this->testCreateNew();
     //Create new first
     $category = Category::find('1');
     $category->delete();
     $result = Category::find('1');
     $this->assertTrue($result == null);
 }
Esempio n. 3
0
 public static function printCategory($id)
 {
     $category = Category::find($id);
     if ($category != null) {
         echo "<ul>";
         echo "<li><a href='" . $category->id . "'>" . $category->name . "</a>";
         foreach (Category::where('category_id', $id)->where('active', true)->get() as $cat) {
             Category::printCategory($cat->id);
         }
         echo "</li>";
         echo "</ul>";
     }
 }