Fix Routes, Fix Ptero User ID, Show ReferredBy (#829)
This commit is contained in:
commit
84d8fceafc
|
@ -142,7 +142,7 @@ class RegisterController extends Controller
|
||||||
$user->syncRoles(4);
|
$user->syncRoles(4);
|
||||||
|
|
||||||
$response = $this->pterodactyl->application->post('/application/users', [
|
$response = $this->pterodactyl->application->post('/application/users', [
|
||||||
'external_id' => $user->pterodactyl_id,
|
'external_id' => null,
|
||||||
'username' => $user->name,
|
'username' => $user->name,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'first_name' => $user->name,
|
'first_name' => $user->name,
|
||||||
|
@ -152,6 +152,14 @@ class RegisterController extends Controller
|
||||||
'language' => 'en',
|
'language' => 'en',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'pterodactyl_id' => $response->json()['attributes']['id'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($response->failed()) {
|
if ($response->failed()) {
|
||||||
$user->delete();
|
$user->delete();
|
||||||
Log::error('Pterodactyl Registration Error: ' . $response->json()['errors'][0]['detail']);
|
Log::error('Pterodactyl Registration Error: ' . $response->json()['errors'][0]['detail']);
|
||||||
|
|
|
@ -15,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Spatie\Activitylog\LogOptions;
|
use Spatie\Activitylog\LogOptions;
|
||||||
use Spatie\Activitylog\Traits\CausesActivity;
|
use Spatie\Activitylog\Traits\CausesActivity;
|
||||||
use Spatie\Activitylog\Traits\LogsActivity;
|
use Spatie\Activitylog\Traits\LogsActivity;
|
||||||
|
@ -97,6 +98,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
|
|
||||||
$ptero_settings = new PterodactylSettings();
|
$ptero_settings = new PterodactylSettings();
|
||||||
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
$this->pterodactyl = new PterodactylClient($ptero_settings);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function boot()
|
public static function boot()
|
||||||
|
@ -285,6 +288,17 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||||
])->save();
|
])->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
|
public function getActivitylogOptions(): LogOptions
|
||||||
{
|
{
|
||||||
return LogOptions::defaults()
|
return LogOptions::defaults()
|
||||||
|
|
|
@ -76,9 +76,11 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
|
||||||
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
|
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
|
||||||
Route::resource('servers', ServerController::class);
|
Route::resource('servers', ServerController::class);
|
||||||
|
|
||||||
$serverSettings = app(App\Settings\ServerSettings::class);
|
if (config('app.key')) {
|
||||||
if ($serverSettings->enable_upgrade) {
|
$serverSettings = app(App\Settings\ServerSettings::class);
|
||||||
Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade');
|
if ($serverSettings->enable_upgrade) {
|
||||||
|
Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser');
|
Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser');
|
||||||
|
|
|
@ -173,18 +173,6 @@
|
||||||
</div>
|
</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="col-lg-6">
|
||||||
|
@ -199,7 +187,30 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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="col-lg-6">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
|
|
Loading…
Reference in a new issue