public static function edit($id)
 {
     if (!Request::is_admin()) {
         Response::redirect('');
     }
     if ("POST" == Request::method()) {
         $id = Request::POST()->id;
         $name = Request::POST()->name;
         $decsription = Request::POST()->description;
         Categories::update($id, $name, $decsription);
         # push flash-message
         Session::push('flash-message', 'That category has changed successfuly!');
         Response::redirect('categories');
     } else {
         $category = Categories::findByPK($id);
         $categories = Categories::all()->fetchAll(\PDO::FETCH_CLASS);
         View::render('categories/add', ['category' => $category, 'categories' => $categories]);
     }
 }
 public function newCategory($id)
 {
     if ($_POST) {
         $request = (object) $_POST;
         $category = new Categories();
         if (isset($id)) {
             $category->update($id, $request->nombre, $request->descripcion);
             newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " actualizada.");
             return redirect('admin/category');
         } else {
             $category->create($request->nombre, $request->descripcion);
             newFlashMessage('test', 'Categoria ' . ucwords($request->nombre) . " creada.");
             return redirect('admin/category/');
         }
     } elseif (isset($id)) {
         $categories = new Categories();
         $category = $categories->find($id);
         return view('admin/categories/update', compact('category'), 'baseAdmin');
     } else {
         return view('admin/categories/create', '', 'baseAdmin');
     }
 }