/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function putUpdate(Request $request, $id) { $validation = Validator::make($request->all(), Term::$rules); if ($validation->fails()) { return Redirect::back()->withInput()->withErrors($validation)->with('error', 'There were validation errors.'); } $term = Term::find($id); $term->name = $request->name; $term->save(); return Redirect::to(action('\\Trexology\\Taxonomy\\Controllers\\TermsController@getIndex', ['id' => $term->vocabulary_id]))->with('success', 'Updated'); }
public function saveOrderTerms($content, $parent_term) { foreach ($content as $child_key => $child) { $child_term = Term::find($child->id); $child_term->parent = $parent_term; $child_term->weight = $child_key; $child_term->save(); if (!empty($child->children)) { $this->saveOrderTerms($child->children, $child->id); } } }