Merge pull request #423 from 1day2die/buy_server_slots
Add the Ability to buy/sell Server slots
This commit is contained in:
commit
453bbd081c
|
@ -23,7 +23,7 @@ class OverViewController extends Controller
|
||||||
});
|
});
|
||||||
|
|
||||||
$creditCount = Cache::remember('credit:count', self::TTL, function () {
|
$creditCount = Cache::remember('credit:count', self::TTL, function () {
|
||||||
return User::query()->sum('credits');
|
return User::query()->where("role","!=","admin")->sum('credits');
|
||||||
});
|
});
|
||||||
|
|
||||||
$paymentCount = Cache::remember('payment:count', self::TTL, function () {
|
$paymentCount = Cache::remember('payment:count', self::TTL, function () {
|
||||||
|
|
|
@ -164,9 +164,6 @@ class PaymentController extends Controller
|
||||||
$response = $this->getPayPalClient()->execute($request);
|
$response = $this->getPayPalClient()->execute($request);
|
||||||
if ($response->statusCode == 201 || $response->statusCode == 200) {
|
if ($response->statusCode == 201 || $response->statusCode == 200) {
|
||||||
|
|
||||||
//update credits
|
|
||||||
$user->increment('credits', $creditProduct->quantity);
|
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
||||||
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
||||||
|
@ -174,6 +171,14 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update User with bought item
|
||||||
|
if ($creditProduct->type=="Credits") {
|
||||||
|
$user->increment('credits', $creditProduct->quantity);
|
||||||
|
}elseif ($creditProduct->type=="Server slots"){
|
||||||
|
$user->increment('server_limit', $creditProduct->quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//update role
|
//update role
|
||||||
if ($user->role == 'member') {
|
if ($user->role == 'member') {
|
||||||
$user->update(['role' => 'client']);
|
$user->update(['role' => 'client']);
|
||||||
|
@ -184,7 +189,7 @@ class PaymentController extends Controller
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'payment_id' => $response->result->id,
|
'payment_id' => $response->result->id,
|
||||||
'payment_method' => 'paypal',
|
'payment_method' => 'paypal',
|
||||||
'type' => 'Credits',
|
'type' => $creditProduct->type,
|
||||||
'status' => 'paid',
|
'status' => 'paid',
|
||||||
'amount' => $creditProduct->quantity,
|
'amount' => $creditProduct->quantity,
|
||||||
'price' => $creditProduct->price,
|
'price' => $creditProduct->price,
|
||||||
|
@ -305,8 +310,7 @@ class PaymentController extends Controller
|
||||||
// check if payment is 100% completed and payment does not exist in db already
|
// check if payment is 100% completed and payment does not exist in db already
|
||||||
if ($paymentSession->status == "complete" && $paymentIntent->status == "succeeded" && $paymentDbEntry == 0) {
|
if ($paymentSession->status == "complete" && $paymentIntent->status == "succeeded" && $paymentDbEntry == 0) {
|
||||||
|
|
||||||
//update credits
|
|
||||||
$user->increment('credits', $creditProduct->quantity);
|
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
||||||
|
@ -315,6 +319,13 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update User with bought item
|
||||||
|
if ($creditProduct->type=="Credits") {
|
||||||
|
$user->increment('credits', $creditProduct->quantity);
|
||||||
|
}elseif ($creditProduct->type=="Server slots"){
|
||||||
|
$user->increment('server_limit', $creditProduct->quantity);
|
||||||
|
}
|
||||||
|
|
||||||
//update role
|
//update role
|
||||||
if ($user->role == 'member') {
|
if ($user->role == 'member') {
|
||||||
$user->update(['role' => 'client']);
|
$user->update(['role' => 'client']);
|
||||||
|
@ -325,7 +336,7 @@ class PaymentController extends Controller
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'payment_id' => $paymentSession->payment_intent,
|
'payment_id' => $paymentSession->payment_intent,
|
||||||
'payment_method' => 'stripe',
|
'payment_method' => 'stripe',
|
||||||
'type' => 'Credits',
|
'type' => $creditProduct->type,
|
||||||
'status' => 'paid',
|
'status' => 'paid',
|
||||||
'amount' => $creditProduct->quantity,
|
'amount' => $creditProduct->quantity,
|
||||||
'price' => $creditProduct->price,
|
'price' => $creditProduct->price,
|
||||||
|
@ -356,7 +367,7 @@ class PaymentController extends Controller
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'payment_id' => $paymentSession->payment_intent,
|
'payment_id' => $paymentSession->payment_intent,
|
||||||
'payment_method' => 'stripe',
|
'payment_method' => 'stripe',
|
||||||
'type' => 'Credits',
|
'type' => $creditProduct->type,
|
||||||
'status' => 'processing',
|
'status' => 'processing',
|
||||||
'amount' => $creditProduct->quantity,
|
'amount' => $creditProduct->quantity,
|
||||||
'price' => $creditProduct->price,
|
'price' => $creditProduct->price,
|
||||||
|
@ -405,8 +416,7 @@ class PaymentController extends Controller
|
||||||
$user = User::where('id', $payment->user_id)->first();
|
$user = User::where('id', $payment->user_id)->first();
|
||||||
|
|
||||||
if ($paymentIntent->status == 'succeeded' && $payment->status == 'processing') {
|
if ($paymentIntent->status == 'succeeded' && $payment->status == 'processing') {
|
||||||
// Increment User Credits
|
|
||||||
$user->increment('credits', $payment->amount);
|
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
||||||
|
@ -414,6 +424,12 @@ class PaymentController extends Controller
|
||||||
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
|
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//update User with bought item
|
||||||
|
if ($creditProduct->type=="Credits") {
|
||||||
|
$user->increment('credits', $creditProduct->quantity);
|
||||||
|
}elseif ($creditProduct->type=="Server slots"){
|
||||||
|
$user->increment('server_limit', $creditProduct->quantity);
|
||||||
|
}
|
||||||
|
|
||||||
//update role
|
//update role
|
||||||
if ($user->role == 'member') {
|
if ($user->role == 'member') {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class StoreController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('store.index')->with([
|
return view('store.index')->with([
|
||||||
'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
|
'products' => CreditProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
|
||||||
'isPaymentSetup' => $isPaymentSetup,
|
'isPaymentSetup' => $isPaymentSetup,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,17 +42,17 @@ class WelcomeMessage extends Notification implements ShouldQueue
|
||||||
|
|
||||||
$AdditionalLine = "";
|
$AdditionalLine = "";
|
||||||
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
||||||
$AdditionalLine .= "Verifying your e-mail address will grant you " . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') . " additional " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
$AdditionalLine .= __("Verifying your e-mail address will grant you ") . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL'). " " . __("additional") . " " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
||||||
}
|
}
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') != 0) {
|
||||||
$AdditionalLine .= "Verifying your e-mail will also increase your Server Limit by " . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . ". <br />";
|
$AdditionalLine .= __("Verifying your e-mail will also increase your Server Limit by ") . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') . ". <br />";
|
||||||
}
|
}
|
||||||
$AdditionalLine .= "<br />";
|
$AdditionalLine .= "<br />";
|
||||||
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
if (config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
||||||
$AdditionalLine .= "You can also verify your discord account to get another " . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
$AdditionalLine .= __("You can also verify your discord account to get another ") . config('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') . " " . config('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') . ". <br />";
|
||||||
}
|
}
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') != 0) {
|
||||||
$AdditionalLine .= "Verifying your Discord account will also increase your Server Limit by " . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . ". <br />";
|
$AdditionalLine .= __("Verifying your Discord account will also increase your Server Limit by ") . config('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') . ". <br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $AdditionalLine;
|
return $AdditionalLine;
|
||||||
|
@ -65,19 +65,20 @@ class WelcomeMessage extends Notification implements ShouldQueue
|
||||||
*/
|
*/
|
||||||
public function toArray($notifiable)
|
public function toArray($notifiable)
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => __("Getting started!"),
|
'title' => __("Getting started!"),
|
||||||
'content' => "
|
'content' => "
|
||||||
<p>Hello <strong>{$this->user->name}</strong>, Welcome to our dashboard!</p>
|
<p> ".__("Hello")." <strong>{$this->user->name}</strong>, ".__("Welcome to our dashboard")."!</p>
|
||||||
<h5>Verification</h5>
|
<h5>".__("Verification")."</h5>
|
||||||
<p>You can verify your e-mail address and link/verify your Discord account.</p>
|
<p>".__("You can verify your e-mail address and link/verify your Discord account.")."</p>
|
||||||
<p>
|
<p>
|
||||||
" . $this->AdditionalLines() . "
|
" . $this->AdditionalLines() . "
|
||||||
</p>
|
</p>
|
||||||
<h5>Information</h5>
|
<h5>".__("Information")."</h5>
|
||||||
<p>This dashboard can be used to create and delete servers.<br /> These servers can be used and managed on our pterodactyl panel.<br /> If you have any questions, please join our Discord server and #create-a-ticket.</p>
|
<p>".__("This dashboard can be used to create and delete servers").".<br /> ".__("These servers can be used and managed on our pterodactyl panel").".<br /> ".__("If you have any questions, please join our Discord server and #create-a-ticket").".</p>
|
||||||
<p>We hope you can enjoy this hosting experience and if you have any suggestions please let us know!</p>
|
<p>".__("We hope you can enjoy this hosting experience and if you have any suggestions please let us know")."!</p>
|
||||||
<p>Regards,<br />" . config('app.name', 'Laravel') . "</p>
|
<p>".__("Regards").",<br />" . config('app.name', 'Laravel') . "</p>
|
||||||
",
|
",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use App\Models\Settings;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'version' => '0.7.4',
|
'version' => '0.7.5',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
<select required name="type" id="type"
|
<select required name="type" id="type"
|
||||||
class="custom-select @error('name') is-invalid @enderror">
|
class="custom-select @error('name') is-invalid @enderror">
|
||||||
<option selected value="Credits">{{CREDITS_DISPLAY_NAME}}</option>
|
<option selected value="Credits">{{CREDITS_DISPLAY_NAME}}</option>
|
||||||
|
<option value="Server slots">{{__("Server Slots")}}</option>
|
||||||
</select>
|
</select>
|
||||||
@error('name')
|
@error('name')
|
||||||
<div class="text-danger">
|
<div class="text-danger">
|
||||||
|
|
|
@ -49,10 +49,12 @@
|
||||||
<a href="{{ route('home') }}" class="nav-link"><i
|
<a href="{{ route('home') }}" class="nav-link"><i
|
||||||
class="fas fa-home mr-2"></i>{{ __('Home') }}</a>
|
class="fas fa-home mr-2"></i>{{ __('Home') }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@if(config('SETTINGS::DISCORD:INVITE_URL'))
|
||||||
<li class="nav-item d-none d-sm-inline-block">
|
<li class="nav-item d-none d-sm-inline-block">
|
||||||
<a href="{{ config('SETTINGS::DISCORD:INVITE_URL') }}" class="nav-link" target="__blank"><i
|
<a href="{{ config('SETTINGS::DISCORD:INVITE_URL') }}" class="nav-link" target="__blank"><i
|
||||||
class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
|
class="fab fa-discord mr-2"></i>{{ __('Discord') }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@endif
|
||||||
<!-- Language Selection -->
|
<!-- Language Selection -->
|
||||||
@if (config('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') == 'true')
|
@if (config('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') == 'true')
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a class=""
|
<li class="breadcrumb-item"><a class=""
|
||||||
href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
||||||
<li class="breadcrumb-item"><a class="text-muted"
|
<li class="breadcrumb-item"><a class="text-muted"
|
||||||
href="{{ route('store.index') }}">{{ __('Store') }}</a></li>
|
href="{{ route('store.index') }}">{{ __('Store') }}</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -41,27 +41,34 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-striped table-responsive-sm">
|
<table class="table table-striped table-responsive-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ __('Price') }}</th>
|
<th>{{ __('Price') }}</th>
|
||||||
<th>{{ __('Type') }}</th>
|
<th>{{ __('Type') }}</th>
|
||||||
<th>{{ __('Description') }}</th>
|
<th>{{ __('Description') }}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php /** @var $product CreditProduct */
|
<?php /** @var $product CreditProduct */
|
||||||
?>
|
?>
|
||||||
@foreach ($products as $product)
|
@foreach ($products as $product)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $product->formatToCurrency($product->price) }}</td>
|
<td>{{ $product->formatToCurrency($product->price) }}</td>
|
||||||
<td>{{ strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type }}
|
<td>{{ strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type }}
|
||||||
</td>
|
</td>
|
||||||
<td><i class="fa fa-coins mr-2"></i>{{ $product->display }}</td>
|
<td>
|
||||||
<td><a href="{{ route('checkout', $product->id) }}"
|
@if(strtolower($product->type) == 'credits')
|
||||||
class="btn btn-info">{{ __('Purchase') }}</a>
|
<i class="fa fa-coins mr-2"></i>
|
||||||
</td>
|
@elseif (strtolower($product->type) == 'server slots')
|
||||||
</tr>
|
<i class="fa fa-server mr-2"></i>
|
||||||
@endforeach
|
@endif
|
||||||
|
|
||||||
|
{{ $product->display }}</td>
|
||||||
|
<td><a href="{{ route('checkout', $product->id) }}"
|
||||||
|
class="btn btn-info">{{ __('Purchase') }}</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -87,7 +94,6 @@
|
||||||
const urlParams = new URLSearchParams(queryString);
|
const urlParams = new URLSearchParams(queryString);
|
||||||
return urlParams.get(param);
|
return urlParams.get(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
const voucherCode = getUrlParameter('voucher');
|
const voucherCode = getUrlParameter('voucher');
|
||||||
//if voucherCode not empty, open the modal and fill the input
|
//if voucherCode not empty, open the modal and fill the input
|
||||||
if (voucherCode) {
|
if (voucherCode) {
|
||||||
|
@ -95,7 +101,6 @@
|
||||||
$('#redeemVoucherModal').modal('show');
|
$('#redeemVoucherModal').modal('show');
|
||||||
$('#redeemVoucherCode').val(voucherCode);
|
$('#redeemVoucherCode').val(voucherCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue