(Update) User Online Block 🚀

This commit is contained in:
HDVinnie
2019-04-14 09:54:36 -04:00
parent e043b7d12a
commit 49f647895c
+12 -2
View File
@@ -83,10 +83,20 @@ class HomeController extends Controller
$posts = Post::latest()->take(5)->get();
// Online Block
$current = Carbon::now();
$expiresAt = $current->addMinutes(60);
$cached_users = cache()->remember('online-users', $expiresAt, function () {
return User::pluck('id');
});
$users = User::with(['privacy', 'group' => function ($query) {
$query->select(['id', 'name', 'color', 'effect', 'icon', 'position']);
}])->select(['id', 'username', 'hidden', 'group_id'])->oldest('username')->get();
$groups = Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get();
}])->whereIn('id', $cached_users)->select(['id', 'username', 'hidden', 'group_id'])->oldest('username')->get();
$groups = cache()->remember('user-groups', $expiresAt, function () {
return Group::select(['name', 'color', 'effect', 'icon'])->oldest('position')->get();
});
// Featured Torrents Block
$featured = FeaturedTorrent::with('torrent')->get();