update: user warnings

- bump pagination to 10
- The warnings panel is now split by warning types. Automated (Torrents), Manual (Staff) and Soft Deleted (whether manual or automated). The counts in tabs are total whether active or not. The Active warning count and total hit run count are in top right of profile.
This commit is contained in:
HDVinnie
2023-07-04 13:33:28 -04:00
parent 96be51efb7
commit 6d85c0f572
3 changed files with 104 additions and 12 deletions
+11 -3
View File
@@ -41,6 +41,8 @@ class UserController extends Controller
'filledRequests' => fn ($query) => $query->whereNotNull('approved_by'),
'requests',
'userwarning as active_warnings_count' => fn ($query) => $query->where('active', '=', 1),
'userwarning as auto_warnings_count' => fn ($query) => $query->whereNotNull('torrent'),
'userwarning as manual_warnings_count' => fn ($query) => $query->whereNull('torrent'),
'userwarning as soft_deleted_warnings_count' => fn ($query) => $query->onlyTrashed(),
])
->with([
@@ -65,15 +67,21 @@ class UserController extends Controller
->selectRaw('SUM(actual_downloaded > 0) as download_count')
->selectRaw('COUNT(*) as count')
->first(),
'warnings' => $user
'manualWarnings' => $user
->userwarning()
->whereNull('torrent')
->latest()
->paginate(10, ['*'], 'warningsPage'),
->paginate(10, ['*'], 'manualWarningsPage'),
'autoWarnings' => $user
->userwarning()
->whereNotNull('torrent')
->latest()
->paginate(10, ['*'], 'autoWarningsPage'),
'softDeletedWarnings' => $user
->userwarning()
->onlyTrashed()
->with(['torrenttitle', 'warneduser'])
->latest('created_at')
->onlyTrashed()
->paginate(10, ['*'], 'deletedWarningsPage'),
'boughtUpload' => BonTransactions::where('sender', '=', $user->id)->where([['name', 'like', '%Upload%']])->sum('cost'),
// 'boughtDownload' => BonTransactions::where('sender', '=', $user->id)->where([['name', 'like', '%Download%']])->sum('cost'),