Beispiel #1
0
 /**
  * Check if the Model instance has the passed term as an existing relation
  *
  * @param mixed $term_id
  *  The ID of the term or an instance of the Term object
  *
  * @return object
  *  The TermRelation object
  */
 public function hasTerm($term_id)
 {
     $term = $term_id instanceof Term ? $term_id : Term::findOrFail($term_id);
     $term_relation = ['term_id' => $term->id, 'vocabulary_id' => $term->vocabulary_id];
     return $this->related()->where('term_id', $term_id)->count() ? TRUE : FALSE;
 }
Beispiel #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function deleteDestroy($id)
 {
     // Delete children if any exist
     Term::whereParent($id)->delete();
     // Delete Term
     Term::destroy($id);
     return Redirect::back();
 }
 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);
         }
     }
 }