Charges the first hour worth of credits upon creating a server.

This commit is contained in:
AVMG20 2021-09-15 08:37:43 +02:00
parent 822d3b9540
commit f4237b2e88
2 changed files with 14 additions and 0 deletions

View file

@ -74,6 +74,12 @@ class ServerController extends Controller
'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');
}

View file

@ -128,6 +128,14 @@ class ConfigurationSeeder extends Seeder
'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.'
]);
}
}