diff --git a/app/Events/UserUpdatedEvent.php b/app/Events/UserUpdatedEvent.php new file mode 100644 index 00000000..199dada6 --- /dev/null +++ b/app/Events/UserUpdatedEvent.php @@ -0,0 +1,32 @@ +user = $user; + } +} diff --git a/app/Http/Controllers/Api/NotificationController.php b/app/Http/Controllers/Api/NotificationController.php index 2371e524..ceecbb24 100644 --- a/app/Http/Controllers/Api/NotificationController.php +++ b/app/Http/Controllers/Api/NotificationController.php @@ -31,7 +31,7 @@ class NotificationController extends Controller /** * Display a specific notification - * + * * @param int $userId * @param int $notificationId * @return JsonResponse @@ -52,9 +52,8 @@ class NotificationController extends Controller /** * Send a notification to an user. - * + * * @param Request $request - * @param int $userId * @return JsonResponse */ public function send(Request $request) @@ -88,7 +87,7 @@ class NotificationController extends Controller /** * Delete all notifications from an user - * + * * @param int $userId * @return JsonResponse */ @@ -105,7 +104,7 @@ class NotificationController extends Controller /** * Delete a specific notification - * + * * @param int $userId * @param int $notificationId * @return JsonResponse diff --git a/app/Listeners/UnsuspendServers.php b/app/Listeners/UnsuspendServers.php new file mode 100644 index 00000000..8bcecbe0 --- /dev/null +++ b/app/Listeners/UnsuspendServers.php @@ -0,0 +1,30 @@ +user->credits > Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER' , 50)){ + /** @var Server $server */ + foreach ($event->user->servers as $server){ + if ($server->isSuspended()) $server->unSuspend(); + } + } + } +} diff --git a/app/Models/User.php b/app/Models/User.php index a4f68ec4..b31d9bd2 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Classes\Pterodactyl; +use App\Events\UserUpdatedEvent; use App\Notifications\Auth\QueuedVerifyEmail; use App\Notifications\WelcomeMessage; use Illuminate\Contracts\Auth\MustVerifyEmail; @@ -111,6 +112,10 @@ class User extends Authenticatable implements MustVerifyEmail Pterodactyl::client()->delete("/application/users/{$user->pterodactyl_id}"); }); + + static::updated(function (User $user){ + event(new UserUpdatedEvent($user)); + }); } /** diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index ae9c40bc..cb150ed5 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,6 +2,8 @@ namespace App\Providers; +use App\Events\UserUpdatedEvent; +use App\Listeners\UnsuspendServers; use App\Listeners\Verified; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; @@ -20,6 +22,9 @@ class EventServiceProvider extends ServiceProvider Registered::class => [ SendEmailVerificationNotification::class, ], + UserUpdatedEvent::class => [ + UnsuspendServers::class + ], SocialiteWasCalled::class => [ // ... other providers 'SocialiteProviders\\Discord\\DiscordExtendSocialite@handle', diff --git a/config/app.php b/config/app.php index 11d8d417..592e97d2 100644 --- a/config/app.php +++ b/config/app.php @@ -2,6 +2,7 @@ return [ + 'version' => '0.5', /* |-------------------------------------------------------------------------- | Application Name diff --git a/resources/views/layouts/main.blade.php b/resources/views/layouts/main.blade.php index 8af86ac3..1f01b180 100644 --- a/resources/views/layouts/main.blade.php +++ b/resources/views/layouts/main.blade.php @@ -21,7 +21,7 @@ {{-- select2 --}} - + @@ -319,7 +319,7 @@