Fix Ticket System

Fix Ticket System
This commit is contained in:
Dennis 2022-11-29 00:57:44 -08:00 committed by GitHub
commit 70f4ff13c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 110 additions and 39 deletions

View file

@ -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'));
}
}
}

View file

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

View file

@ -1,10 +1,8 @@
<?php
use App\Models\Settings;
return [
'version' => '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))),
/*

View file

@ -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,
];
}
}

View file

@ -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');
});
}
}

View file

@ -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>
@ -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
@ -221,15 +224,18 @@
</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>
@ -246,14 +252,15 @@
</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">
@ -261,7 +268,8 @@
</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">
@ -271,17 +279,15 @@
</div>
</div>
</div>
@endforeach
</div>
@endforeach
</div>
</div>
</div>
<!-- END CUSTOM CONTENT -->
</div>
</section>
<!-- END CONTENT -->
@endsection