@@ -187,12 +187,12 @@ |
||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Get all promotions with their statistics |
| 190 | - $promotions = RolePromotion::withCount(['statistics' => function ($query) use ($startDate, $endDate) { |
|
| 190 | + $promotions = RolePromotion::withCount(['statistics' => function($query) use ($startDate, $endDate) { |
|
| 191 | 191 | if ($startDate) { |
| 192 | 192 | $query->whereBetween('applied_at', [$startDate, $endDate]); |
| 193 | 193 | } |
| 194 | 194 | }]) |
| 195 | - ->with(['statistics' => function ($query) use ($startDate, $endDate) { |
|
| 195 | + ->with(['statistics' => function($query) use ($startDate, $endDate) { |
|
| 196 | 196 | if ($startDate) { |
| 197 | 197 | $query->whereBetween('applied_at', [$startDate, $endDate]); |
| 198 | 198 | } |
@@ -124,7 +124,7 @@ |
||
| 124 | 124 | return [ |
| 125 | 125 | 'total_promotions_received' => $stats->count(), |
| 126 | 126 | 'total_days_added' => $stats->sum('days_added'), |
| 127 | - 'promotions' => $stats->groupBy('role_promotion_id')->map(function ($group) { |
|
| 127 | + 'promotions' => $stats->groupBy('role_promotion_id')->map(function($group) { |
|
| 128 | 128 | return [ |
| 129 | 129 | 'promotion_id' => $group->first()->role_promotion_id, |
| 130 | 130 | 'promotion_name' => $group->first()->promotion?->name, |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $now = Carbon::now(); |
| 71 | 71 | return $query->where('is_active', true) |
| 72 | - ->where(function ($q) use ($now) { |
|
| 72 | + ->where(function($q) use ($now) { |
|
| 73 | 73 | $q->whereNull('end_date') |
| 74 | 74 | ->orWhere('end_date', '>=', $now); |
| 75 | 75 | }) |
| 76 | - ->where(function ($q) use ($now) { |
|
| 76 | + ->where(function($q) use ($now) { |
|
| 77 | 77 | $q->whereNull('start_date') |
| 78 | 78 | ->orWhere('start_date', '<=', $now); |
| 79 | 79 | }); |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | $query = static::where('is_active', true); |
| 119 | 119 | |
| 120 | 120 | $now = Carbon::now(); |
| 121 | - $query->where(function ($q) use ($now) { |
|
| 121 | + $query->where(function($q) use ($now) { |
|
| 122 | 122 | $q->whereNull('start_date') |
| 123 | 123 | ->orWhere('start_date', '<=', $now); |
| 124 | 124 | }); |
| 125 | 125 | |
| 126 | - $query->where(function ($q) use ($now) { |
|
| 126 | + $query->where(function($q) use ($now) { |
|
| 127 | 127 | $q->whereNull('end_date') |
| 128 | 128 | ->orWhere('end_date', '>=', $now); |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | 131 | if ($roleId !== null) { |
| 132 | - $query->where(function ($q) use ($roleId) { |
|
| 132 | + $query->where(function($q) use ($roleId) { |
|
| 133 | 133 | // If applicable_roles is empty, applies to all custom roles |
| 134 | 134 | $q->whereJsonLength('applicable_roles', 0) |
| 135 | 135 | ->orWhereJsonContains('applicable_roles', $roleId); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | ->with('role') |
| 210 | 210 | ->get() |
| 211 | 211 | ->groupBy('role_id') |
| 212 | - ->map(function ($stats, $roleId) { |
|
| 212 | + ->map(function($stats, $roleId) { |
|
| 213 | 213 | return [ |
| 214 | 214 | 'role_id' => $roleId, |
| 215 | 215 | 'role_name' => $stats->first()->role?->name, |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | $res = self::query()->withTrashed()->where('email', '<>', '[email protected]'); |
| 271 | 271 | |
| 272 | - if (! empty($role)) { |
|
| 272 | + if (!empty($role)) { |
|
| 273 | 273 | $res->where('roles_id', $role); |
| 274 | 274 | } |
| 275 | 275 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | 'rate_limit' => $rateLimit ? $rateLimit['rate_limit'] : 60, |
| 319 | 319 | ]; |
| 320 | 320 | |
| 321 | - if (! empty($email)) { |
|
| 321 | + if (!empty($email)) { |
|
| 322 | 322 | $email = trim($email); |
| 323 | 323 | $sql += ['email' => $email]; |
| 324 | 324 | } |
@@ -427,12 +427,12 @@ discard block |
||
| 427 | 427 | return self::fromQuery( |
| 428 | 428 | sprintf( |
| 429 | 429 | $query, |
| 430 | - ! empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
| 431 | - ! empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
| 432 | - ! empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
| 433 | - (! empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
| 434 | - ! empty($createdFrom) ? 'AND users.created_at >= '.escapeString($createdFrom.' 00:00:00') : '', |
|
| 435 | - ! empty($createdTo) ? 'AND users.created_at <= '.escapeString($createdTo.' 23:59:59') : '', |
|
| 430 | + !empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
| 431 | + !empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
| 432 | + !empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
| 433 | + (!empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
| 434 | + !empty($createdFrom) ? 'AND users.created_at >= '.escapeString($createdFrom.' 00:00:00') : '', |
|
| 435 | + !empty($createdTo) ? 'AND users.created_at <= '.escapeString($createdTo.' 23:59:59') : '', |
|
| 436 | 436 | $order[0], |
| 437 | 437 | $order[1], |
| 438 | 438 | ($start === false ? '' : ('LIMIT '.$offset.' OFFSET '.$start)) |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | |
| 545 | 545 | public static function isValidUrl($url): bool |
| 546 | 546 | { |
| 547 | - return (! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
| 547 | + return (!preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | |
| 581 | 581 | // Make sure this is the last check, as if a further validation check failed, the invite would still have been used up. |
| 582 | 582 | $invitedBy = 0; |
| 583 | - if (! $forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
| 583 | + if (!$forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
| 584 | 584 | if ($inviteCode === '') { |
| 585 | 585 | return self::ERR_SIGNUP_BADINVITECODE; |
| 586 | 586 | } |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | public static function checkAndUseInvite(string $inviteCode): int |
| 601 | 601 | { |
| 602 | 602 | $invite = Invitation::findValidByToken($inviteCode); |
| 603 | - if (! $invite) { |
|
| 603 | + if (!$invite) { |
|
| 604 | 604 | return -1; |
| 605 | 605 | } |
| 606 | 606 | |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | public static function add(string $userName, string $password, string $email, int $role, ?string $notes = '', string $host = '', int $invites = Invitation::DEFAULT_INVITES, int $invitedBy = 0) |
| 617 | 617 | { |
| 618 | 618 | $password = self::hashPassword($password); |
| 619 | - if (! $password) { |
|
| 619 | + if (!$password) { |
|
| 620 | 620 | return false; |
| 621 | 621 | } |
| 622 | 622 | |
@@ -658,9 +658,9 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | $cats = ['view console', 'view movies', 'view audio', 'view tv', 'view pc', 'view adult', 'view books', 'view other']; |
| 660 | 660 | |
| 661 | - if (! empty($allowed)) { |
|
| 661 | + if (!empty($allowed)) { |
|
| 662 | 662 | foreach ($cats as $cat) { |
| 663 | - if (! \in_array($cat, $allowed, false)) { |
|
| 663 | + if (!\in_array($cat, $allowed, false)) { |
|
| 664 | 664 | $ret[] = match ($cat) { |
| 665 | 665 | 'view console' => 1000, |
| 666 | 666 | 'view movies' => 2000, |
@@ -257,13 +257,13 @@ |
||
| 257 | 257 | UserRoleHistory::recordRoleChange( |
| 258 | 258 | userId: $user->id, |
| 259 | 259 | oldRoleId: $oldRole ? $oldRole->id : null, |
| 260 | - newRoleId: $pendingRole ? $pendingRole->id : $user->roles_id, |
|
| 261 | - oldExpiryDate: null, |
|
| 262 | - newExpiryDate: null, |
|
| 263 | - effectiveDate: $now, |
|
| 264 | - isStacked: true, |
|
| 265 | - changeReason: 'manual_activation', |
|
| 266 | - changedBy: null |
|
| 260 | + newRoleId : $pendingRole ? $pendingRole->id : $user->roles_id, |
|
| 261 | + oldExpiryDate : null, |
|
| 262 | + newExpiryDate : null, |
|
| 263 | + effectiveDate : $now, |
|
| 264 | + isStacked : true, |
|
| 265 | + changeReason : 'manual_activation', |
|
| 266 | + changedBy : null |
|
| 267 | 267 | ); |
| 268 | 268 | |
| 269 | 269 | $this->info(sprintf( |
@@ -32,28 +32,28 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if ($request->has('username') && !empty($request->input('username'))) { |
| 35 | - $query->whereHas('user', function ($q) use ($request) { |
|
| 36 | - $q->where('username', 'like', '%' . $request->input('username') . '%'); |
|
| 35 | + $query->whereHas('user', function($q) use ($request) { |
|
| 36 | + $q->where('username', 'like', '%'.$request->input('username').'%'); |
|
| 37 | 37 | }); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | if ($request->has('role_id') && !empty($request->input('role_id'))) { |
| 41 | - $query->where(function ($q) use ($request) { |
|
| 41 | + $query->where(function($q) use ($request) { |
|
| 42 | 42 | $q->where('old_role_id', $request->input('role_id')) |
| 43 | 43 | ->orWhere('new_role_id', $request->input('role_id')); |
| 44 | 44 | }); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | if ($request->has('change_reason') && !empty($request->input('change_reason'))) { |
| 48 | - $query->where('change_reason', 'like', '%' . $request->input('change_reason') . '%'); |
|
| 48 | + $query->where('change_reason', 'like', '%'.$request->input('change_reason').'%'); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if ($request->has('date_from') && !empty($request->input('date_from'))) { |
| 52 | - $query->where('created_at', '>=', $request->input('date_from') . ' 00:00:00'); |
|
| 52 | + $query->where('created_at', '>=', $request->input('date_from').' 00:00:00'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if ($request->has('date_to') && !empty($request->input('date_to'))) { |
| 56 | - $query->where('created_at', '<=', $request->input('date_to') . ' 23:59:59'); |
|
| 56 | + $query->where('created_at', '<=', $request->input('date_to').' 23:59:59'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Pagination |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->setAdminPrefs(); |
| 89 | 89 | |
| 90 | 90 | $user = User::findOrFail($userId); |
| 91 | - $meta_title = $title = 'Role History for ' . $user->username; |
|
| 91 | + $meta_title = $title = 'Role History for '.$user->username; |
|
| 92 | 92 | |
| 93 | 93 | $history = UserRoleHistory::with(['oldRole', 'newRole', 'changedByUser']) |
| 94 | 94 | ->where('user_id', $userId) |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | // Add country data to each user based on their host IP |
| 63 | 63 | foreach ($results as $user) { |
| 64 | 64 | $position = null; |
| 65 | - if (! empty($user->host) && filter_var($user->host, FILTER_VALIDATE_IP)) { |
|
| 65 | + if (!empty($user->host) && filter_var($user->host, FILTER_VALIDATE_IP)) { |
|
| 66 | 66 | $position = Location::get($user->host); |
| 67 | 67 | } |
| 68 | 68 | $user->country_name = $position ? $position->countryName : null; |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $adminManuallySetExpiry = false; |
| 186 | 186 | if ($request->has('rolechangedate')) { |
| 187 | 187 | $roleChangeDate = $request->input('rolechangedate'); |
| 188 | - if (! empty($roleChangeDate)) { |
|
| 188 | + if (!empty($roleChangeDate)) { |
|
| 189 | 189 | User::updateUserRoleChangeDate($editedUser->id, $roleChangeDate); |
| 190 | 190 | $adminManuallySetExpiry = true; // Flag that admin set custom expiry |
| 191 | 191 | } else { |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | $enabled = $config['enabled'] ?? true; |
| 55 | 55 | $workAvailable = $config['work_available'] ?? true; |
| 56 | 56 | |
| 57 | - if (! $pane || ! $command) { |
|
| 57 | + if (!$pane || !$command) { |
|
| 58 | 58 | return false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Check if task is enabled and has work |
| 62 | - if (! $enabled) { |
|
| 62 | + if (!$enabled) { |
|
| 63 | 63 | return $this->disablePane($pane, $taskName, 'disabled in settings'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if (! $workAvailable) { |
|
| 66 | + if (!$workAvailable) { |
|
| 67 | 67 | return $this->disablePane($pane, $taskName, 'no work available'); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $logsEnabled = (int) Settings::settingValue('write_logs') === 1; |
| 131 | 131 | |
| 132 | - if (! $logsEnabled) { |
|
| 132 | + if (!$logsEnabled) { |
|
| 133 | 133 | return '/dev/null'; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $logDir = config('tmux.paths.logs', storage_path('logs/tmux')); |
| 137 | 137 | |
| 138 | - if (! is_dir($logDir)) { |
|
| 138 | + if (!is_dir($logDir)) { |
|
| 139 | 139 | mkdir($logDir, 0755, true); |
| 140 | 140 | } |
| 141 | 141 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $killswitch = $config['killswitch']['pp'] ?? false; |
| 203 | 203 | $pane = '0.1'; |
| 204 | 204 | |
| 205 | - if (! $enabled) { |
|
| 205 | + if (!$enabled) { |
|
| 206 | 206 | return $this->disablePane($pane, 'Update Binaries', 'disabled in settings'); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | default => null, |
| 216 | 216 | }; |
| 217 | 217 | |
| 218 | - if (! $artisanCommand) { |
|
| 218 | + if (!$artisanCommand) { |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $ppKillswitch = $config['killswitch']['pp'] ?? false; |
| 238 | 238 | $pane = '0.2'; |
| 239 | 239 | |
| 240 | - if (! $enabled) { |
|
| 240 | + if (!$enabled) { |
|
| 241 | 241 | return $this->disablePane($pane, 'Backfill', 'disabled in settings'); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | default => null, |
| 252 | 252 | }; |
| 253 | 253 | |
| 254 | - if (! $artisanCommand) { |
|
| 254 | + if (!$artisanCommand) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $enabled = (int) ($config['settings']['releases_run'] ?? 0); |
| 280 | 280 | $pane = $config['pane'] ?? '0.3'; |
| 281 | 281 | |
| 282 | - if (! $enabled) { |
|
| 282 | + if (!$enabled) { |
|
| 283 | 283 | return $this->disablePane($pane, 'Update Releases', 'disabled in settings'); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | |
| 443 | 443 | // Trim whitespace and filter out empty values and '0' |
| 444 | 444 | $types = array_map('trim', $types); |
| 445 | - $types = array_filter($types, fn ($type) => ! empty($type) && $type !== '0'); |
|
| 445 | + $types = array_filter($types, fn ($type) => !empty($type) && $type !== '0'); |
|
| 446 | 446 | |
| 447 | 447 | // Re-index array to ensure sequential keys |
| 448 | 448 | $types = array_values($types); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | */ |
| 490 | 490 | protected function loadCrapState(string $file): array |
| 491 | 491 | { |
| 492 | - if (! file_exists($file)) { |
|
| 492 | + if (!file_exists($file)) { |
|
| 493 | 493 | return ['first_run' => true]; |
| 494 | 494 | } |
| 495 | 495 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | protected function saveCrapState(string $file, array $state): void |
| 506 | 506 | { |
| 507 | 507 | $dir = dirname($file); |
| 508 | - if (! is_dir($dir)) { |
|
| 508 | + if (!is_dir($dir)) { |
|
| 509 | 509 | mkdir($dir, 0755, true); |
| 510 | 510 | } |
| 511 | 511 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | return $this->disablePane($pane, 'Post-process Movies', 'disabled in settings'); |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - if (! $hasMoviesWork) { |
|
| 667 | + if (!$hasMoviesWork) { |
|
| 668 | 668 | return $this->disablePane($pane, 'Post-process Movies', 'no work available'); |
| 669 | 669 | } |
| 670 | 670 | |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | || (int) ($runVar['counts']['now']['processconsole'] ?? 0) > 0 |
| 703 | 703 | || (int) ($runVar['counts']['now']['processgames'] ?? 0) > 0; |
| 704 | 704 | |
| 705 | - if (! $hasWork) { |
|
| 705 | + if (!$hasWork) { |
|
| 706 | 706 | return $this->disablePane($pane, 'Post-process Amazon', 'no music/books/games to process'); |
| 707 | 707 | } |
| 708 | 708 | |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | |
| 767 | 767 | $hasWork = (int) ($runVar['counts']['now']['processxxx'] ?? 0) > 0; |
| 768 | 768 | |
| 769 | - if (! $hasWork) { |
|
| 769 | + if (!$hasWork) { |
|
| 770 | 770 | return $this->disablePane($pane, 'Post-process XXX', 'no XXX releases to process'); |
| 771 | 771 | } |
| 772 | 772 | |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | $this->info(' |