From 5c26f1e8ab95a5b104b52ef0c742416e66533513 Mon Sep 17 00:00:00 2001 From: Julian Prieber Date: Wed, 15 Feb 2023 15:53:55 +0100 Subject: [PATCH] Updated users table Added new fields to the users table. Added ability to sort users table alphabetically. --- app/Http/Controllers/AdminController.php | 18 +++-- resources/views/panel/users.blade.php | 87 ++++++++++++++++++++---- 2 files changed, 86 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 414d8e7..502c408 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -50,23 +50,33 @@ public function users(Request $request) switch ($usersType) { case 'all': - $users = User::select('id', 'name', 'email', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); + $users = User::select('id', 'name', 'email', 'littlelink_name', 'role', 'block', 'email_verified_at', 'created_at')->get(); break; case 'user': - $users = User::where('role', 'user')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); + $users = User::where('role', 'user')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at', 'created_at')->get(); break; case 'vip': - $users = User::where('role', 'vip')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); + $users = User::where('role', 'vip')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at', 'created_at')->get(); break; case 'admin': - $users = User::where('role', 'admin')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); + $users = User::where('role', 'admin')->select('id', 'email', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at', 'created_at')->get(); break; } $data['users'] = $users; + + // Loop through each user to get their click count and link count + foreach ($users as $user) { + $clicks = Link::where('user_id', $user->id)->sum('click_number'); + $links = Link::where('user_id', $user->id)->select('link')->count(); + $user->clicks = $clicks; + $user->links = $links; + } + return view('panel/users', $data); } + //Search user by name public function searchUser(Request $request) { diff --git a/resources/views/panel/users.blade.php b/resources/views/panel/users.blade.php index e47721f..167ac80 100755 --- a/resources/views/panel/users.blade.php +++ b/resources/views/panel/users.blade.php @@ -2,7 +2,7 @@ @section('content') - +

Users

@@ -31,24 +31,36 @@ - - - - - - - @if(env('REGISTER_AUTH') !== 'auth')@endif - - + + + + + + + + + + + @if(env('REGISTER_AUTH') !== 'auth')@endif + + @foreach($users as $user) + created_at; + $date = date('d.m.Y', strtotime($dateString)); + ?> - - - - + + + + + + + + @if(env('REGISTER_AUTH') !== 'auth') @@ -77,5 +89,50 @@ + + + +@endsection \ No newline at end of file
NameE-MailPageRoleEditLinksE-Mail VerifiedBlockDelete userIDNameE-MailPageRoleTotal linksTotal clicksCreated atEditLinksE-Mail VerifiedBlockDelete user
{{ $user->name }} {{ $user->email }}   {{ $user->littlelink_name }} {{ $user->role }}{{ $user->id }} {{ $user->name }} {{ $user->email }} @if(isset($user->littlelink_name))  {{ $user->littlelink_name }} @else N/A @endif{{ $user->role }}{{$user->links}}{{$user->clicks}}{{$date}} Edit View