get(['tag'])->toArray(); TagUtil::recordsString2Array($blogs, 'tag'); $tags = []; foreach ($blogs as $blog) { foreach ($blog['tag'] as $t) { if (isset($tags[$t])) { $tags[$t]++; } else { $tags[$t] = 1; } } } return $tags; }); } public static function records() { $all = self::all(); $records = array_build($all, function ($k, $v) { return [$k, ['name' => $k, 'count' => $v]]; }); $records = ArrayUtil::sortByKey($records, 'count', 'desc'); return $records; } }