/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $validation = Validator::make(Input::all(), Term::$rules);
     if ($validation->fails()) {
         return Redirect::back()->withInput()->withErrors($validation)->with('error', 'There were validation errors.');
     }
     $term = Term::find($id);
     $term->name = Input::get('name');
     $term->save();
     return Redirect::route($this->route_prefix . 'taxonomy.edit', $term->vocabulary->id);
 }
 public function orderTerms($id)
 {
     $this->vocabulary->find($id);
     $request = \Request::instance();
     $json = $request->getContent();
     $content = json_decode($json);
     foreach ($content as $parent_key => $parent) {
         $parent_term = Term::find($parent->id);
         $parent_term->parent = 0;
         $parent_term->weight = $parent_key;
         $parent_term->save();
         if (empty($parent->children)) {
             continue;
         }
         foreach ($parent->children as $child_key => $child) {
             $child_term = Term::find($child->id);
             $child_term->parent = $parent_term->id;
             $child_term->weight = $child_key;
             $child_term->save();
         }
     }
 }