Show referredBy on User

This commit is contained in:
1day2die 2023-05-08 23:00:29 +02:00
parent 166dccd3de
commit 6f74a7379f
2 changed files with 38 additions and 13 deletions

View file

@ -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()

View file

@ -173,18 +173,6 @@
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
<label>{{ __('Usage') }}</label>
</div>
<div class="col-lg-8">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
<i class="fas fa-coins mr-2"></i>{{ $user->CreditUsage() }}
</span>
</div>
</div>
</div>
<div class="col-lg-6">
@ -199,7 +187,30 @@
</div>
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
<label>{{ __('Usage') }}</label>
</div>
<div class="col-lg-8">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
<i class="fas fa-coins mr-2"></i>{{ $user->CreditUsage() }}
</span>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
<label>{{ __('Referred by') }}</label>
</div>
<div class="col-lg-8">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
{{ $user->referredBy() != Null ? $user->referredBy()->name : "None" }}
</span>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">