Ejemplo n.º 1
0
 /**
  * Find a model by its primary key.
  *
  * @param  mixed  $id
  * @param  array  $columns
  * @return \Illuminate\Support\Collection|static
  */
 public function find($id)
 {
     $model = Term::find($id);
     if ($model) {
         return $model;
     }
     throw new ResourceNotFoundException('Term was not found.');
 }
Ejemplo n.º 2
0
 /**
  *
  * @param string $type            
  * @param array $args            
  *
  * @return array
  * 
  * @see https://developer.wordpress.org/reference/functions/get_terms/
  */
 protected static function getTermsWithTotalsBy($type, $args = [])
 {
     if (!count($args)) {
         $args = ['orderby' => 'name,count', 'hide_empty' => true];
     }
     $terms = [];
     foreach (get_terms($type, $args) as $_t) {
         $term = Term::find($_t->term_id);
         $term->total = $_t->count;
         $terms[] = $term;
     }
     return $terms;
 }