Skip to content

Commit

Permalink
Merge pull request #601 from ControlPanel-gg/development
Browse files Browse the repository at this point in the history
0.8.3.2 Ticket FIx
  • Loading branch information
1day2die authored Nov 29, 2022
2 parents 5bc5ae8 + 70f4ff1 commit de967cf
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 39 deletions.
10 changes: 5 additions & 5 deletions app/Listeners/Verified.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Listeners;

use App\Models\Settings;

class Verified
{
/**
Expand All @@ -19,12 +17,14 @@ public function __construct()
/**
* Handle the event.
*
* @param object $event
* @param object $event
* @return void
*/
public function handle($event)
{
$event->user->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
$event->user->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
if (!$event->user->email_verified_reward) {
$event->user->increment('server_limit', config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL'));
$event->user->increment('credits', config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'));
}
}
}
43 changes: 34 additions & 9 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Models;

use App\Classes\Pterodactyl;
use App\Events\UserUpdateCreditsEvent;
use App\Notifications\Auth\QueuedVerifyEmail;
use App\Notifications\WelcomeMessage;
use Illuminate\Contracts\Auth\MustVerifyEmail;
Expand Down Expand Up @@ -110,8 +109,17 @@ public static function boot()
}
});

$user->tickets()->chunk(10, function ($tickets) {
foreach ($tickets as $ticket) {
$ticket->delete();
}
});

$user->ticketBlackList()->delete();

$user->vouchers()->detach();


$user->discordUser()->delete();

Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}");
Expand All @@ -134,6 +142,22 @@ public function payments()
return $this->hasMany(Payment::class);
}

/**
* @return HasMany
*/
public function tickets()
{
return $this->hasMany(Ticket::class);
}

/**
* @return HasMany
*/
public function ticketBlackList()
{
return $this->hasMany(TicketBlacklist::class);
}

/**
* @return BelongsToMany
*/
Expand Down Expand Up @@ -209,6 +233,13 @@ public function unSuspend()
return $this;
}

private function getServersWithProduct()
{
return $this->servers()
->with('product')
->get();
}

/**
* @return string
*/
Expand All @@ -233,19 +264,13 @@ public function getAvatar()
* @return string
*/
public function creditUsage()
{
{
$usage = 0;
foreach ($this->getServersWithProduct() as $server) {
$usage += $server->product->price;
}

return number_format($usage, 2, '.', '');
}

private function getServersWithProduct() {
return $this->servers()
->with('product')
->get();
}

/**
Expand All @@ -266,7 +291,7 @@ public function verifyEmail()
'email_verified_at' => now(),
])->save();
}

public function reVerifyEmail()
{
$this->forceFill([
Expand Down
10 changes: 4 additions & 6 deletions config/app.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php

use App\Models\Settings;

return [

'version' => '0.8.3.1',
'version' => '0.8.3.2',

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -43,7 +41,7 @@
|
*/

'debug' => (bool) env('APP_DEBUG', false),
'debug' => (bool)env('APP_DEBUG', false),

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -85,7 +83,7 @@
|
*/

'locale' =>"en",
'locale' => "en",

/*
|--------------------------------------------------------------------------
Expand All @@ -98,7 +96,7 @@
|
*/

'available_locales' => array_map('basename', preg_replace('/\\.[^.\\s]{3,4}$/', '', glob(resource_path()."/lang/*.json", GLOB_BRACE))),
'available_locales' => array_map('basename', preg_replace('/\\.[^.\\s]{3,4}$/', '', glob(resource_path() . "/lang/*.json", GLOB_BRACE))),


/*
Expand Down
3 changes: 2 additions & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public function definition()
return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'credits' => $this->faker->numberBetween(0,1500),
'credits' => $this->faker->numberBetween(0, 1500),
'last_seen' => $this->faker->dateTimeBetween(now(), '+30 days'),
'email_verified_at' => $this->faker->dateTimeBetween('-30 days', now()),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
'email_verified' => true,
];
}
}
41 changes: 41 additions & 0 deletions database/migrations/2022_11_29_075851_email_verify_d_b.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class EmailVerifyDB extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('email_verified_reward')->default(false);
});

$existing_user = User::whereNotNull('email_verified_at')->get();

foreach ($existing_user as $user) {
$user->email_verified_reward = true;
$user->save();
}
}


/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('email_verified_reward');
});
}
}
42 changes: 24 additions & 18 deletions resources/views/admin/users/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{route('home')}}">{{__('Dashboard')}}</a></li>
<li class="breadcrumb-item"><a href="{{route('admin.users.index')}}">{{__('Users')}}</a></li>
<li class="breadcrumb-item"><a class="text-muted" href="{{route('admin.users.show' , $user->id)}}">{{__('Show')}}</a></li>
<li class="breadcrumb-item"><a class="text-muted"
href="{{route('admin.users.show' , $user->id)}}">{{__('Show')}}</a>
</li>
</ol>
</div>
</div>
Expand All @@ -30,11 +32,12 @@
<div class="small-box bg-dark">
<div class="d-flex justify-content-between">
<div class="p-3">
<h3>{{$user->discordUser->username}} <sup>{{$user->discordUser->locale}}</sup> </h3>
<h3>{{$user->discordUser->username}} <sup>{{$user->discordUser->locale}}</sup></h3>
<p>{{$user->discordUser->id}}
</p>
</div>
<div class="p-3"><img width="100px" height="100px" class="rounded-circle" src="{{$user->discordUser->getAvatar()}}" alt="avatar"></div>
<div class="p-3"><img width="100px" height="100px" class="rounded-circle"
src="{{$user->discordUser->getAvatar()}}" alt="avatar"></div>
</div>
<div class="small-box-footer">
<i class="fab fa-discord mr-1"></i>Discord
Expand Down Expand Up @@ -221,15 +224,18 @@ class="d-inline-block text-truncate badge {{$user->role == 'admin' || $user->rol
</div>
<div class="col-lg-8">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
@if($user->last_seen) {{$user->last_seen->diffForHumans()}} @else <small
class="text-muted">Null</small> @endif
@if($user->last_seen)
{{$user->last_seen->diffForHumans()}}
@else
<small
class="text-muted">Null</small>
@endif
</span>
</div>
</div>
</div>



</div>

</div>
Expand All @@ -246,22 +252,24 @@ class="text-muted">Null</small> @endif
</div>

</div>
<div class="card">
<div class="card-header">
<h5 class="card-title"><i class="fas fa-user-check mr-2"></i>{{__('Referals')}} ({{__("referral-code")}}: {{$user->referral_code}})</h5>
</div>
<div class="card-body table-responsive">
<div class="card">
<div class="card-header">
<h5 class="card-title"><i class="fas fa-user-check mr-2"></i>{{__('Referals')}}
({{__("referral-code")}}: {{$user->referral_code}})</h5>
</div>
<div class="card-body table-responsive">


@foreach($referrals as $referral)
@foreach($referrals as $referral)
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
<label>User ID: {{$referral->id}}</label>
</div>
<div class="col-lg-4">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
<i class="fas fa-user-check mr-2"></i><a href="{{route("admin.users.show",$referral->id)}}">{{$referral->name}}</a>
<i class="fas fa-user-check mr-2"></i><a
href="{{route("admin.users.show",$referral->id)}}">{{$referral->name}}</a>
</span>
</div>
<div class="col-lg-4">
Expand All @@ -271,17 +279,15 @@ class="text-muted">Null</small> @endif
</div>
</div>
</div>
@endforeach
</div>

@endforeach
</div>

</div>

</div>
<!-- END CUSTOM CONTENT -->
</div>
</section>
<!-- END CONTENT -->



@endsection

0 comments on commit de967cf

Please sign in to comment.