Example #1
0
 /**
  * Get entry terms
  * @return TermCollection
  */
 public function terms($entryId, $taxonomyId = null)
 {
     $query = Term::join('entry_term', 'entry_term.term_id', '=', 'terms.id')->where('entry_term.entry_id', $entryId);
     // Add taxonomy
     if ($taxonomyId) {
         $query->where('entry_term.taxonomy_id', $taxonomyId);
     }
     // Get terms
     $terms = $query->get();
     return new TermCollection($terms->toArray());
 }
Example #2
0
 public function existsByTitle($title, $taxonomyId = null)
 {
     if ($taxonomyId) {
         $term = Term::where('title', 'like', $title)->first();
     } else {
         $term = Term::where('title', 'like', $title)->where('taxonomy_id', $taxonomyId)->first();
     }
     if ($term) {
         return $term->id;
     }
 }