mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-30 07:20:25 -05:00
(Update) Group Queries 🚀
- add caching to system required groups
This commit is contained in:
@@ -44,13 +44,16 @@ class AutoBan extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
|
||||
$bans = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.max_warnings'))->get();
|
||||
|
||||
foreach ($bans as $ban) {
|
||||
if ($ban->warneduser->group_id != $bannedGroup->id && ! $ban->warneduser->group->is_immune) {
|
||||
if ($ban->warneduser->group_id != $banned_group[0] && ! $ban->warneduser->group->is_immune) {
|
||||
// If User Has x or More Active Warnings Ban Set The Users Group To Banned
|
||||
$ban->warneduser->group_id = $bannedGroup->id;
|
||||
$ban->warneduser->group_id = $banned_group[0];
|
||||
$ban->warneduser->can_upload = 0;
|
||||
$ban->warneduser->can_download = 0;
|
||||
$ban->warneduser->can_comment = 0;
|
||||
|
||||
@@ -43,7 +43,10 @@ class AutoDisableInactiveUsers extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('pruning.user_pruning') == true) {
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
|
||||
$current = Carbon::now();
|
||||
|
||||
$matches = User::whereIn('group_id', [config('pruning.group_ids')]);
|
||||
@@ -54,7 +57,7 @@ class AutoDisableInactiveUsers extends Command
|
||||
|
||||
foreach ($users as $user) {
|
||||
if ($user->getSeeding() !== 0) {
|
||||
$user->group_id = $disabledGroup->id;
|
||||
$user->group_id = $disabled_group[0];
|
||||
$user->can_upload = 0;
|
||||
$user->can_download = 0;
|
||||
$user->can_comment = 0;
|
||||
|
||||
@@ -42,14 +42,24 @@ class AutoRevokePermissions extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$leechGroup = Group::select(['id'])->where('slug', '=', 'leech')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$leech_group = cache()->rememberForever('leech_group', function () {
|
||||
return Group::where('slug', '=', 'leech')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
User::whereNotIn('group_id', [$bannedGroup->id, $validatingGroup->id, $leechGroup->id, $disabledGroup->id, $prunedGroup->id])->update(['can_download' => '1', 'can_request' => '1']);
|
||||
User::whereIn('group_id', [$bannedGroup->id, $validatingGroup->id, $leechGroup->id, $disabledGroup->id, $prunedGroup->id])->update(['can_download' => '0', 'can_request' => '0']);
|
||||
User::whereNotIn('group_id', [$banned_group[0], $validating_group[0], $leech_group[0], $disabled_group[0], $pruned_group[0]])->update(['can_download' => '1', 'can_request' => '1']);
|
||||
User::whereIn('group_id', [$banned_group[0], $validating_group[0], $leech_group[0], $disabled_group[0], $pruned_group[0]])->update(['can_download' => '0', 'can_request' => '0']);
|
||||
|
||||
$warning = Warning::with('warneduser')->select(DB::raw('user_id, count(*) as value'))->where('active', '=', 1)->groupBy('user_id')->having('value', '>=', config('hitrun.revoke'))->get();
|
||||
|
||||
|
||||
@@ -43,11 +43,15 @@ class AutoSoftDeleteDisabledUsers extends Command
|
||||
public function handle()
|
||||
{
|
||||
if (config('pruning.user_pruning') == true) {
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
$current = Carbon::now();
|
||||
$users = User::where('group_id', '=', $disabledGroup->id)
|
||||
$users = User::where('group_id', '=', $disabled_group[0])
|
||||
->where('disabled_at', '<', $current->copy()->subDays(config('pruning.soft_delete'))->toDateTimeString())
|
||||
->get();
|
||||
|
||||
@@ -61,7 +65,7 @@ class AutoSoftDeleteDisabledUsers extends Command
|
||||
$user->can_invite = 0;
|
||||
$user->can_request = 0;
|
||||
$user->can_chat = 0;
|
||||
$user->group = $prunedGroup->id;
|
||||
$user->group = $pruned_group[0];
|
||||
$user->deleted_by = 1;
|
||||
$user->save();
|
||||
$user->delete();
|
||||
|
||||
@@ -21,18 +21,22 @@ class ActivationController extends Controller
|
||||
{
|
||||
public function activate($token)
|
||||
{
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$member_group = cache()->rememberForever('member_group', function () {
|
||||
return Group::where('slug', '=', 'user')->pluck('id');
|
||||
});
|
||||
|
||||
$activation = UserActivation::with('user')->where('token', '=', $token)->firstOrFail();
|
||||
if ($activation->user->id && $activation->user->group->id != $bannedGroup->id) {
|
||||
if ($activation->user->id && $activation->user->group->id != $banned_group[0]) {
|
||||
$activation->user->active = 1;
|
||||
$activation->user->can_upload = 1;
|
||||
$activation->user->can_download = 1;
|
||||
$activation->user->can_request = 1;
|
||||
$activation->user->can_comment = 1;
|
||||
$activation->user->can_invite = 1;
|
||||
$activation->user->group_id = $memberGroup->id;
|
||||
$activation->user->group_id = $member_group[0];
|
||||
$activation->user->save();
|
||||
|
||||
$activation->delete();
|
||||
|
||||
@@ -67,12 +67,20 @@ class LoginController extends Controller
|
||||
|
||||
protected function authenticated(Request $request, $user)
|
||||
{
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$member_group = cache()->rememberForever('member_group', function () {
|
||||
return Group::where('slug', '=', 'user')->pluck('id');
|
||||
});
|
||||
|
||||
if ($user->active == 0 || $user->group_id == $validatingGroup->id) {
|
||||
if ($user->active == 0 || $user->group_id == $validating_group[0]) {
|
||||
$this->guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
@@ -80,7 +88,7 @@ class LoginController extends Controller
|
||||
->withErrors(trans('auth.not-activated'));
|
||||
}
|
||||
|
||||
if ($user->group_id == $bannedGroup->id) {
|
||||
if ($user->group_id == $banned_group[0]) {
|
||||
$this->guard()->logout();
|
||||
$request->session()->invalidate();
|
||||
|
||||
@@ -88,8 +96,8 @@ class LoginController extends Controller
|
||||
->withErrors(trans('auth.banned'));
|
||||
}
|
||||
|
||||
if ($user->group_id == $disabledGroup->id) {
|
||||
$user->group_id = $memberGroup->id;
|
||||
if ($user->group_id == $disabled_group[0]) {
|
||||
$user->group_id = $member_group[0];
|
||||
$user->can_upload = 1;
|
||||
$user->can_download = 1;
|
||||
$user->can_comment = 1;
|
||||
@@ -103,8 +111,8 @@ class LoginController extends Controller
|
||||
->withSuccess(trans('auth.welcome-restore'));
|
||||
}
|
||||
|
||||
if (auth()->viaRemember() && $user->group_id == $disabledGroup->id) {
|
||||
$user->group_id = $memberGroup->id;
|
||||
if (auth()->viaRemember() && $user->group_id == $disabled_group[0]) {
|
||||
$user->group_id = $member_group[0];
|
||||
$user->can_upload = 1;
|
||||
$user->can_download = 1;
|
||||
$user->can_comment = 1;
|
||||
|
||||
@@ -78,7 +78,10 @@ class RegisterController extends Controller
|
||||
->withErrors(trans('auth.invalid-key'));
|
||||
}
|
||||
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
|
||||
$user = new User();
|
||||
$user->username = $request->input('username');
|
||||
$user->email = $request->input('email');
|
||||
@@ -89,7 +92,7 @@ class RegisterController extends Controller
|
||||
$user->downloaded = config('other.default_download');
|
||||
$user->style = config('other.default_style', 0);
|
||||
$user->locale = config('app.locale');
|
||||
$user->group_id = $validatingGroup->id;
|
||||
$user->group_id = $validating_group[0];
|
||||
|
||||
if (config('email-white-blacklist.enabled') === 'allow' && config('captcha.enabled') == true) {
|
||||
$v = validator($request->all(), [
|
||||
|
||||
@@ -33,13 +33,17 @@ class ResetPasswordController extends Controller
|
||||
|
||||
protected function resetPassword($user, $password)
|
||||
{
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$member_group = cache()->rememberForever('member_group', function () {
|
||||
return Group::where('slug', '=', 'user')->pluck('id');
|
||||
});
|
||||
$user->password = bcrypt($password);
|
||||
$user->remember_token = Str::random(60);
|
||||
|
||||
if ($user->group_id === $validatingGroup->id) {
|
||||
$user->group_id = $memberGroup->id;
|
||||
if ($user->group_id === $validating_group[0]) {
|
||||
$user->group_id = $member_group[0];
|
||||
}
|
||||
|
||||
$user->active = true;
|
||||
|
||||
@@ -146,13 +146,17 @@ class RssController extends Controller
|
||||
$user = User::where('rsskey', '=', (string) $rsskey)->firstOrFail();
|
||||
$rss = Rss::where('id', '=', (int) $id)->whereRaw('(user_id = ? OR is_private != ?)', [$user->id, 1])->firstOrFail();
|
||||
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
|
||||
if ($user->group->id == $bannedGroup->id) {
|
||||
if ($user->group->id == $banned_group[0]) {
|
||||
abort(404);
|
||||
}
|
||||
if ($user->group->id == $disabledGroup->id) {
|
||||
if ($user->group->id == $disabled_group[0]) {
|
||||
abort(404);
|
||||
}
|
||||
if ($user->active == 0) {
|
||||
|
||||
@@ -49,11 +49,13 @@ class BanController extends Controller
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
$staff = $request->user();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
|
||||
abort_if($user->group->is_modo || $request->user()->id == $user->id, 403);
|
||||
|
||||
$user->group_id = $bannedGroup->id;
|
||||
$user->group_id = $banned_group[0];
|
||||
$user->can_upload = 0;
|
||||
$user->can_download = 0;
|
||||
$user->can_comment = 0;
|
||||
|
||||
@@ -36,11 +36,15 @@ class HomeController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
// User Info
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$num_user = User::count();
|
||||
$banned = User::where('group_id', '=', $bannedGroup->id)->count();
|
||||
$validating = User::where('group_id', '=', $validatingGroup->id)->count();
|
||||
$banned = User::where('group_id', '=', $banned_group[0])->count();
|
||||
$validating = User::where('group_id', '=', $validating_group[0])->count();
|
||||
|
||||
// Torrent Info
|
||||
$num_torrent = Torrent::count();
|
||||
|
||||
@@ -40,7 +40,6 @@ class MassActionController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$staff = $request->user();
|
||||
$users = User::all();
|
||||
|
||||
$sender_id = 1;
|
||||
@@ -72,12 +71,16 @@ class MassActionController extends Controller
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$memberGroup = Group::select(['id'])->where('slug', '=', 'user')->first();
|
||||
$users = User::where('active', '=', 0)->where('group_id', '=', $validatingGroup->id)->get();
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$member_group = cache()->rememberForever('member_group', function () {
|
||||
return Group::where('slug', '=', 'user')->pluck('id');
|
||||
});
|
||||
$users = User::where('active', '=', 0)->where('group_id', '=', $validating_group[0])->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user->group_id = $memberGroup->id;
|
||||
$user->group_id = $member_group[0];
|
||||
$user->active = 1;
|
||||
$user->can_upload = 1;
|
||||
$user->can_download = 1;
|
||||
|
||||
@@ -52,33 +52,47 @@ class StatsController extends Controller
|
||||
|
||||
// Total Active Members Count (Not Validating, Banned, Disabled, Pruned)
|
||||
$active_user = cache()->remember('active_user', $this->expiresAt, function () {
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
return User::whereNotIn('group_id', [$validatingGroup->id, $bannedGroup->id, $disabledGroup->id, $prunedGroup->id])->count();
|
||||
return User::whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->count();
|
||||
});
|
||||
|
||||
// Total Disabled Members Count
|
||||
$disabled_user = cache()->remember('disabled_user', $this->expiresAt, function () {
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
|
||||
return User::where('group_id', '=', $disabledGroup->id)->count();
|
||||
return User::where('group_id', '=', $disabled_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Pruned Members Count
|
||||
$pruned_user = cache()->remember('pruned_user', $this->expiresAt, function () {
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
return User::onlyTrashed()->where('group_id', '=', $prunedGroup->id)->count();
|
||||
return User::onlyTrashed()->where('group_id', '=', $pruned_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Banned Members Count
|
||||
$banned_user = cache()->remember('banned_user', $this->expiresAt, function () {
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
|
||||
return User::where('group_id', '=', $bannedGroup->id)->count();
|
||||
return User::where('group_id', '=', $banned_group[0])->count();
|
||||
});
|
||||
|
||||
// Total Torrents Count
|
||||
@@ -175,13 +189,21 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function uploaded()
|
||||
{
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
// Fetch Top Uploaders
|
||||
$uploaded = User::latest('uploaded')->whereNotIn('group_id', [$validatingGroup->id, $bannedGroup->id, $disabledGroup->id, $prunedGroup->id])->take(100)->get();
|
||||
$uploaded = User::latest('uploaded')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
|
||||
return view('stats.users.uploaded', ['uploaded' => $uploaded]);
|
||||
}
|
||||
@@ -193,13 +215,21 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function downloaded()
|
||||
{
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
// Fetch Top Downloaders
|
||||
$downloaded = User::latest('downloaded')->whereNotIn('group_id', [$validatingGroup->id, $bannedGroup->id, $disabledGroup->id, $prunedGroup->id])->take(100)->get();
|
||||
$downloaded = User::latest('downloaded')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
|
||||
return view('stats.users.downloaded', ['downloaded' => $downloaded]);
|
||||
}
|
||||
@@ -250,13 +280,21 @@ class StatsController extends Controller
|
||||
*/
|
||||
public function bankers()
|
||||
{
|
||||
$validatingGroup = Group::select(['id'])->where('slug', '=', 'validating')->first();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$disabledGroup = Group::select(['id'])->where('slug', '=', 'disabled')->first();
|
||||
$prunedGroup = Group::select(['id'])->where('slug', '=', 'pruned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
$validating_group = cache()->rememberForever('validating_group', function () {
|
||||
return Group::where('slug', '=', 'validating')->pluck('id');
|
||||
});
|
||||
$disabled_group = cache()->rememberForever('disabled_group', function () {
|
||||
return Group::where('slug', '=', 'disabled')->pluck('id');
|
||||
});
|
||||
$pruned_group = cache()->rememberForever('pruned_group', function () {
|
||||
return Group::where('slug', '=', 'pruned')->pluck('id');
|
||||
});
|
||||
|
||||
// Fetch Top Bankers
|
||||
$bankers = User::latest('seedbonus')->whereNotIn('group_id', [$validatingGroup->id, $bannedGroup->id, $disabledGroup->id, $prunedGroup->id])->take(100)->get();
|
||||
$bankers = User::latest('seedbonus')->whereNotIn('group_id', [$validating_group[0], $banned_group[0], $disabled_group[0], $pruned_group[0]])->take(100)->get();
|
||||
|
||||
return view('stats.users.bankers', ['bankers' => $bankers]);
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ class CheckIfBanned
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
$user = $request->user();
|
||||
$bannedGroup = Group::select(['id'])->where('slug', '=', 'banned')->first();
|
||||
$banned_group = cache()->rememberForever('banned_group', function () {
|
||||
return Group::where('slug', '=', 'banned')->pluck('id');
|
||||
});
|
||||
|
||||
if ($user && $user->group_id == $bannedGroup->id) {
|
||||
if ($user && $user->group_id == $banned_group[0]) {
|
||||
auth()->logout();
|
||||
$request->session()->flush();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user