public static function getMostUsedApps($count = 5) { $ins = new static(); $token_counts = Token::getAppTokenCounts(); return array_map(function ($app) use($ins) { $info = $ins->where('key', $app['_id'])->first(['_id', 'name', 'key']); $app['id'] = $info->id; $app['name'] = $info->name; $app['key'] = $info->key; unset($app['_id']); return $app; }, array_slice($token_counts, 0, $count)); }