commit
2862109d60
|
@ -74,6 +74,12 @@ class ServerController extends Controller
|
||||||
'identifier' => $response->json()['attributes']['identifier']
|
'identifier' => $response->json()['attributes']['identifier']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (Configuration::getValueByKey('SERVER_CREATE_CHARGE_FIRST_HOUR' , 'true') == 'true'){
|
||||||
|
if (Auth::user()->credits >= $server->product->getHourlyPrice()){
|
||||||
|
Auth::user()->decrement('credits', $server->product->getHourlyPrice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->route('servers.index')->with('success', 'server created');
|
return redirect()->route('servers.index')->with('success', 'server created');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,12 @@ class Server extends Model
|
||||||
|
|
||||||
static::deleting(function (Server $server) {
|
static::deleting(function (Server $server) {
|
||||||
$response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
$response = Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}");
|
||||||
if ($response->failed() && !is_null($server->pterodactyl_id)) throw new Exception($response['errors'][0]['code']);
|
if ($response->failed() && !is_null($server->pterodactyl_id)) {
|
||||||
|
//only return error when it's not a 404 error
|
||||||
|
if ($response['errors'][0]['status'] != '404') {
|
||||||
|
throw new Exception($response['errors'][0]['code']);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,14 @@ class ConfigurationSeeder extends Seeder
|
||||||
'description' => 'Set the display name of your currency :)'
|
'description' => 'Set the display name of your currency :)'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//credits display name
|
||||||
|
Configuration::firstOrCreate([
|
||||||
|
'key' => 'SERVER_CREATE_CHARGE_FIRST_HOUR',
|
||||||
|
], [
|
||||||
|
'value' => 'true',
|
||||||
|
'type' => 'boolean',
|
||||||
|
'description' => 'Charges the first hour worth of credits upon creating a server.'
|
||||||
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue