add: restrict bon upload purchases if buffer is too high

This commit is contained in:
Roardom
2024-11-14 09:06:59 +00:00
parent 8eb1e64cc1
commit d9863fc346
3 changed files with 25 additions and 0 deletions
@@ -71,6 +71,10 @@ class TransactionController extends Controller
switch (true) {
case $bonExchange->upload:
if (config('other.bon.max-buffer-to-buy-upload') !== null && $user->uploaded - $user->downloaded > config('other.bon.max-buffer-to-buy-upload')) {
return back()->withErrors('You already have enough buffer.');
}
$user->increment('uploaded', $bonExchange->value);
break;
+17
View File
@@ -264,4 +264,21 @@ return [
*/
'every' => 5,
],
/*
|--------------------------------------------------------------------------
| BON
|--------------------------------------------------------------------------
| Configures user bon transactions.
*/
'bon' => [
/*
|--------------------------------------------------------------------------
| The maximum allowed account buffer when buying upload.
|--------------------------------------------------------------------------
| null = Disabled
| Example : 10 * 1024 * 1024 * 1024 * 1024
*/
'max-buffer-to-buy-upload' => null,
],
];
@@ -44,6 +44,10 @@
<button disabled class="form__button form__button--filled">
{{ __('bon.activated') }}!
</button>
@elseif ($item->upload && config('other.bon.max-buffer-to-buy-upload') !== null && $user->uploaded - $user->downloaded > config('other.bon.max-buffer-to-buy-upload'))
<button disabled class="form__button form__button--filled">
Too much buffer!
</button>
@else
<form
method="POST"