Beispiel #1
0
 public function snakeToStr($snake)
 {
     return snakeToStr($snake);
 }
Beispiel #2
0
 function getTag($tag, $postType = 'article', $number = 10, array $fields = ['*'], $order = 'asc', $orderBy = 'id')
 {
     $namespace = 'App\\Models\\';
     $classTypeName = studly_case(snakeToStr($postType));
     $class = $namespace . $classTypeName;
     if (!class_exists($class)) {
         $class = 'LiveCMS\\Models\\' . $classTypeName;
     }
     $ids = app($class)->where('status', PostableModel::STATUS_PUBLISHED)->whereHas('tags', function ($query) use($tag) {
         $query->where(function ($query) use($tag) {
             $table = $query->getModel()->getTable();
             $query->where($table . '.tag', $tag)->orWhere($table . '.slug', $tag);
         });
     })->pluck('id')->toArray();
     return get($postType, $ids, $number, [], $fields, $order, $orderBy);
 }