|
@@ -8,6 +8,7 @@ use App\Http\Controllers\Controller;
|
|
|
use App\Models\DiscordUser;
|
|
|
use App\Models\User;
|
|
|
use App\Notifications\ReferralNotification;
|
|
|
+use App\Traits\Referral;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Contracts\Foundation\Application;
|
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
@@ -27,6 +28,8 @@ use Spatie\QueryBuilder\QueryBuilder;
|
|
|
|
|
|
class UserController extends Controller
|
|
|
{
|
|
|
+ use Referral;
|
|
|
+
|
|
|
const ALLOWED_INCLUDES = ['servers', 'notifications', 'payments', 'vouchers', 'discordUser'];
|
|
|
|
|
|
const ALLOWED_FILTERS = ['name', 'server_limit', 'email', 'pterodactyl_id', 'role', 'suspended'];
|
|
@@ -92,7 +95,7 @@ class UserController extends Controller
|
|
|
|
|
|
//Update Users Password on Pterodactyl
|
|
|
//Username,Mail,First and Lastname are required aswell
|
|
|
- $response = Pterodactyl::client()->patch('/application/users/'.$user->pterodactyl_id, [
|
|
|
+ $response = Pterodactyl::client()->patch('/application/users/' . $user->pterodactyl_id, [
|
|
|
'username' => $request->name,
|
|
|
'first_name' => $request->name,
|
|
|
'last_name' => $request->name,
|
|
@@ -229,7 +232,7 @@ class UserController extends Controller
|
|
|
$discordUser = DiscordUser::find($id);
|
|
|
$user = $discordUser ? $discordUser->user : User::findOrFail($id);
|
|
|
|
|
|
- if (! $user->isSuspended()) {
|
|
|
+ if (!$user->isSuspended()) {
|
|
|
throw ValidationException::withMessages([
|
|
|
'error' => 'You cannot unsuspend an User who is not suspended.',
|
|
|
]);
|
|
@@ -240,21 +243,6 @@ class UserController extends Controller
|
|
|
return $user;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Create a unique Referral Code for User
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
- protected function createReferralCode()
|
|
|
- {
|
|
|
- $referralcode = STR::random(8);
|
|
|
- if (User::where('referral_code', '=', $referralcode)->exists()) {
|
|
|
- $this->createReferralCode();
|
|
|
- }
|
|
|
-
|
|
|
- return $referralcode;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @throws ValidationException
|
|
|
*/
|
|
@@ -267,7 +255,7 @@ class UserController extends Controller
|
|
|
]);
|
|
|
|
|
|
// Prevent the creation of new users via API if this is enabled.
|
|
|
- if (! config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
|
|
|
+ if (!config('SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', 'true')) {
|
|
|
throw ValidationException::withMessages([
|
|
|
'error' => 'The creation of new users has been blocked by the system administrator.',
|
|
|
]);
|
|
@@ -305,7 +293,7 @@ class UserController extends Controller
|
|
|
'pterodactyl_id' => $response->json()['attributes']['id'],
|
|
|
]);
|
|
|
//INCREMENT REFERRAL-USER CREDITS
|
|
|
- if (! empty($request->input('referral_code'))) {
|
|
|
+ if (!empty($request->input('referral_code'))) {
|
|
|
$ref_code = $request->input('referral_code');
|
|
|
$new_user = $user->id;
|
|
|
if ($ref_user = User::query()->where('referral_code', '=', $ref_code)->first()) {
|