cleanup
This commit is contained in:
parent
0e5eda1470
commit
6c175c9160
|
@ -1,4 +1,4 @@
|
||||||
APP_NAME=Laravel
|
APP_NAME=Dashboard
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
APP_KEY=
|
APP_KEY=
|
||||||
APP_DEBUG=false
|
APP_DEBUG=false
|
||||||
|
@ -11,6 +11,7 @@ DB_DATABASE=controlpanel
|
||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=root
|
DB_PASSWORD=root
|
||||||
|
|
||||||
|
#paypal details, you only need sandbox for testing! you can do this by setting the APP_ENV to local
|
||||||
PAYPAL_SANDBOX_SECRET=
|
PAYPAL_SANDBOX_SECRET=
|
||||||
PAYPAL_SANDBOX_CLIENT_ID=
|
PAYPAL_SANDBOX_CLIENT_ID=
|
||||||
PAYPAL_SECRET=
|
PAYPAL_SECRET=
|
||||||
|
|
|
@ -40,13 +40,13 @@ class ChargeCreditsCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Server::chunk(10, function ($servers) {
|
Server::chunk(10, function ($servers) {
|
||||||
/** @var Server $server */
|
/** @var Server $server */
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
|
|
||||||
//ignore suspended servers
|
//ignore suspended servers
|
||||||
if ($server->isSuspended()) {
|
if ($server->isSuspended()) {
|
||||||
echo Carbon::now()->isoFormat('LLL') . " Ignoring suspended server";
|
echo Carbon::now()->isoFormat('LLL') . " Ignoring suspended server";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,22 +54,21 @@ class ChargeCreditsCommand extends Command
|
||||||
$user = $server->user;
|
$user = $server->user;
|
||||||
$price = ($server->product->price / 30) / 24;
|
$price = ($server->product->price / 30) / 24;
|
||||||
|
|
||||||
|
|
||||||
//remove credits or suspend server
|
//remove credits or suspend server
|
||||||
if ($user->credits >= $price) {
|
if ($user->credits >= $price) {
|
||||||
$user->decrement('credits', $price);
|
$user->decrement('credits', $price);
|
||||||
|
|
||||||
//log
|
//log
|
||||||
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Removed " . number_format($price, 2, '.', '') . " from user (" . $user->name . ") for server (" . $server->name . ")\n";
|
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Removed " . number_format($price, 2, '.', '') . " from user (" . $user->name . ") for server (" . $server->name . ")\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$response = Pterodactyl::client()->post("/application/servers/{$server->pterodactyl_id}/suspend");
|
$response = Pterodactyl::client()->post("/application/servers/{$server->pterodactyl_id}/suspend");
|
||||||
|
|
||||||
if ($response->successful()) {
|
if ($response->successful()) {
|
||||||
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Suspended server (" . $server->name . ") from user (" . $user->name . ")\n";
|
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] Suspended server (" . $server->name . ") from user (" . $user->name . ")\n";
|
||||||
$server->update(['suspended' => now()]);
|
$server->update(['suspended' => now()]);
|
||||||
} else {
|
} else {
|
||||||
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] CRITICAL ERROR! Unable to suspend server (" . $server->name . ") from user (" . $user->name . ")\n";
|
echo Carbon::now()->isoFormat('LLL') . " [CREDIT DEDUCTION] CRITICAL ERROR! Unable to suspend server (" . $server->name . ") from user (" . $user->name . ")\n";
|
||||||
dump($response->json());
|
dump($response->json());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use App\Classes\Pterodactyl;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class testUserCommand extends TestCase
|
class TestUserCommand extends TestCase
|
||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
Loading…
Reference in a new issue