From 6f74a7379f2fbfa0623688a6cc82f2b00ca75537 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Mon, 8 May 2023 23:00:29 +0200 Subject: [PATCH] Show referredBy on User --- app/Models/User.php | 14 +++++++ .../default/views/admin/users/show.blade.php | 37 ++++++++++++------- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index c72e693c..da4a3a7f 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Facades\DB; use Spatie\Activitylog\LogOptions; use Spatie\Activitylog\Traits\CausesActivity; use Spatie\Activitylog\Traits\LogsActivity; @@ -97,6 +98,8 @@ class User extends Authenticatable implements MustVerifyEmail $ptero_settings = new PterodactylSettings(); $this->pterodactyl = new PterodactylClient($ptero_settings); + + } public static function boot() @@ -285,6 +288,17 @@ class User extends Authenticatable implements MustVerifyEmail ])->save(); } + public function referredBy(){ + $referee = DB::table('user_referrals')->where("registered_user_id",$this->id)->first(); + + if($referee){ + $referee = User::where("id",$referee->referral_id)->firstOrFail(); + return $referee; + } + return Null; + + } + public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() diff --git a/themes/default/views/admin/users/show.blade.php b/themes/default/views/admin/users/show.blade.php index 3ab0d62e..5656c307 100644 --- a/themes/default/views/admin/users/show.blade.php +++ b/themes/default/views/admin/users/show.blade.php @@ -173,18 +173,6 @@ -
-
-
- -
-
- - {{ $user->CreditUsage() }} - -
-
-
@@ -199,7 +187,30 @@
- +
+
+
+ +
+
+ + {{ $user->CreditUsage() }} + +
+
+
+
+
+
+ +
+
+ + {{ $user->referredBy() != Null ? $user->referredBy()->name : "None" }} + +
+
+