diff --git a/app/Listeners/Verified.php b/app/Listeners/Verified.php index 6620cad3..c4932707 100644 --- a/app/Listeners/Verified.php +++ b/app/Listeners/Verified.php @@ -2,8 +2,6 @@ namespace App\Listeners; -use App\Models\Settings; - class Verified { /** @@ -19,12 +17,14 @@ class Verified /** * 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')); + } } } diff --git a/app/Models/User.php b/app/Models/User.php index 450c1c44..31bb29e5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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; @@ -110,8 +109,17 @@ class User extends Authenticatable implements MustVerifyEmail } }); + $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}"); @@ -134,6 +142,22 @@ class User extends Authenticatable implements MustVerifyEmail 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 */ @@ -209,6 +233,13 @@ class User extends Authenticatable implements MustVerifyEmail return $this; } + private function getServersWithProduct() + { + return $this->servers() + ->with('product') + ->get(); + } + /** * @return string */ @@ -233,19 +264,13 @@ class User extends Authenticatable implements MustVerifyEmail * @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(); } /** @@ -266,7 +291,7 @@ class User extends Authenticatable implements MustVerifyEmail 'email_verified_at' => now(), ])->save(); } - + public function reVerifyEmail() { $this->forceFill([ diff --git a/config/app.php b/config/app.php index b8e0c270..19e226d8 100644 --- a/config/app.php +++ b/config/app.php @@ -1,10 +1,8 @@ '0.8.3.1', + 'version' => '0.8.3.2', /* |-------------------------------------------------------------------------- @@ -43,7 +41,7 @@ return [ | */ - 'debug' => (bool) env('APP_DEBUG', false), + 'debug' => (bool)env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- @@ -85,7 +83,7 @@ return [ | */ - 'locale' =>"en", + 'locale' => "en", /* |-------------------------------------------------------------------------- @@ -98,7 +96,7 @@ return [ | */ - '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))), /* diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 9d570417..822e4978 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -25,11 +25,12 @@ class UserFactory extends Factory 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, ]; } } diff --git a/database/migrations/2022_11_29_075851_email_verify_d_b.php b/database/migrations/2022_11_29_075851_email_verify_d_b.php new file mode 100644 index 00000000..04e2663b --- /dev/null +++ b/database/migrations/2022_11_29_075851_email_verify_d_b.php @@ -0,0 +1,41 @@ +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'); + }); + } +} diff --git a/resources/views/admin/users/show.blade.php b/resources/views/admin/users/show.blade.php index 4b6dd5ba..c9cf9b7c 100644 --- a/resources/views/admin/users/show.blade.php +++ b/resources/views/admin/users/show.blade.php @@ -12,7 +12,9 @@
@@ -30,11 +32,12 @@{{$user->discordUser->id}}