Date: Mon, 27 Sep 2021 17:21:17 +0200
Subject: [PATCH 19/66] Added "ran out of Credits"
---
resources/views/home.blade.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 424cd48b..3be09b1a 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -67,7 +67,6 @@
- @if($useage > 0)
@if(number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 15)
@@ -82,7 +81,11 @@
Out of {{CREDITS_DISPLAY_NAME}} in
@if(number_format((Auth::user()->Credits()*30)/$useage,2,'.','') < "1")
- {{number_format(Auth::user()->Credits()/($useage/30/24),0,'.','')}} hours
+ @if(number_format(Auth::user()->Credits()/($useage/30/24),0,'.','') < "1")
+ You ran out of Credits
+ @else
+ {{number_format(Auth::user()->Credits()/($useage/30/24),0,'.','')}} hours
+ @endif
@else
{{number_format((Auth::user()->Credits()*30)/$useage,0,'.','')}} days
@endif
@@ -92,7 +95,6 @@
- @endif
From e708e2fc24df494eeffa495c7a7055f23d1dbd45 Mon Sep 17 00:00:00 2001
From: Dennis
Date: Mon, 27 Sep 2021 18:42:55 +0200
Subject: [PATCH 20/66] Update home.blade.php
This will add the "Out of credits in..." Box when you have and never had Credits.
It will show the box and the text "You ran out of Credits" if you purchased Credits and your servers got Suspended
---
resources/views/home.blade.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 3be09b1a..50b2d0db 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -65,8 +65,9 @@
-
+
+ @if(Auth::user()->Credits() > 0.01 and $useage > 0)
@if(number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 15)
@@ -81,7 +82,7 @@
Out of {{CREDITS_DISPLAY_NAME}} in
@if(number_format((Auth::user()->Credits()*30)/$useage,2,'.','') < "1")
- @if(number_format(Auth::user()->Credits()/($useage/30/24),0,'.','') < "1")
+ @if(number_format(Auth::user()->Credits()/($useage/30/24),2,'.','') < "1")
You ran out of Credits
@else
{{number_format(Auth::user()->Credits()/($useage/30/24),0,'.','')}} hours
@@ -95,10 +96,11 @@
-
+ @endif
+
From b1ca573dd16aceb06cbd37cefd0865da02c586fa Mon Sep 17 00:00:00 2001
From: Johannes
Date: Mon, 27 Sep 2021 18:43:07 +0200
Subject: [PATCH 21/66] User server gets suspended / unsuspended if an user
accounts get suspended / unsuspended
---
app/Models/User.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/app/Models/User.php b/app/Models/User.php
index 9941be37..83fd71bb 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -177,6 +177,10 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function suspend()
{
+ foreach ($this->servers as $server){
+ $server->suspend();
+ }
+
$this->update([
'suspended' => true
]);
@@ -189,6 +193,12 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function unSuspend()
{
+ foreach ($this->servers as $server){
+ if ($this->credits >= $server->product->getHourlyPrice()) {
+ $server->unSuspend();
+ }
+ }
+
$this->update([
'suspended' => false
]);
From 241014134faa582fd037a5edba92ef0d901268b0 Mon Sep 17 00:00:00 2001
From: Johannes
Date: Mon, 27 Sep 2021 20:27:06 +0200
Subject: [PATCH 22/66] Fix formatting
---
app/Models/User.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/Models/User.php b/app/Models/User.php
index 83fd71bb..33501ba0 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -177,7 +177,7 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function suspend()
{
- foreach ($this->servers as $server){
+ foreach ($this->servers as $server) {
$server->suspend();
}
@@ -193,10 +193,10 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function unSuspend()
{
- foreach ($this->servers as $server){
- if ($this->credits >= $server->product->getHourlyPrice()) {
- $server->unSuspend();
- }
+ foreach ($this->servers as $server) {
+ if ($this->credits >= $server->product->getHourlyPrice()) {
+ $server->unSuspend();
+ }
}
$this->update([
From 28af0c053009682e2431deaf118f69eee0391bcb Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Fri, 1 Oct 2021 23:21:49 +0200
Subject: [PATCH 23/66] Add minimal credits per product
---
.../Controllers/Admin/ProductController.php | 14 +-
app/Http/Controllers/ServerController.php | 30 ++-
app/Models/Product.php | 8 +-
..._01_200844_add_product_minimum_credits.php | 32 +++
.../views/admin/products/create.blade.php | 185 +++++++++--------
resources/views/admin/products/edit.blade.php | 190 +++++++++---------
resources/views/admin/products/show.blade.php | 113 ++++++-----
resources/views/servers/create.blade.php | 83 ++++----
8 files changed, 376 insertions(+), 279 deletions(-)
create mode 100644 database/migrations/2021_10_01_200844_add_product_minimum_credits.php
diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php
index 97407644..ffa6856b 100644
--- a/app/Http/Controllers/Admin/ProductController.php
+++ b/app/Http/Controllers/Admin/ProductController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
+use App\Models\Configuration;
use App\Models\Product;
use Exception;
use Illuminate\Contracts\Foundation\Application;
@@ -51,6 +52,7 @@ class ProductController extends Controller
"swap" => "required|numeric|max:1000000|min:0",
"description" => "required|string|max:191",
"disk" => "required|numeric|max:1000000|min:5",
+ "minimum_credits" => "required|numeric|max:1000000|min:-1",
"io" => "required|numeric|max:1000000|min:0",
"databases" => "required|numeric|max:1000000|min:0",
"backups" => "required|numeric|max:1000000|min:0",
@@ -73,7 +75,8 @@ class ProductController extends Controller
public function show(Product $product)
{
return view('admin.products.show', [
- 'product' => $product
+ 'product' => $product,
+ 'minimum_credits' => Configuration::getValueByKey("MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER"),
]);
}
@@ -108,6 +111,7 @@ class ProductController extends Controller
"description" => "required|string|max:191",
"disk" => "required|numeric|max:1000000|min:5",
"io" => "required|numeric|max:1000000|min:0",
+ "minimum_credits" => "required|numeric|max:1000000|min:-1",
"databases" => "required|numeric|max:1000000|min:0",
"backups" => "required|numeric|max:1000000|min:0",
"allocations" => "required|numeric|max:1000000|min:0",
@@ -125,7 +129,8 @@ class ProductController extends Controller
* @param Product $product
* @return RedirectResponse
*/
- public function disable(Request $request, Product $product) {
+ public function disable(Request $request, Product $product)
+ {
$product->update(['disabled' => !$product->disabled]);
return redirect()->route('admin.products.index')->with('success', 'product has been updated!');
@@ -181,12 +186,11 @@ class ProductController extends Controller
' . csrf_field() . '
' . method_field("PATCH") . '
-
-
+
+
';
-
})
->editColumn('created_at', function (Product $product) {
return $product->created_at ? $product->created_at->diffForHumans() : '';
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index f916c52c..2709c3a3 100644
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -16,7 +16,7 @@ use Illuminate\Http\Client\Response;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
-
+use Illuminate\Support\Facades\Request as FacadesRequest;
class ServerController extends Controller
{
@@ -39,6 +39,7 @@ class ServerController extends Controller
$query->where('disabled', '=', false);
})->get(),
'nests' => Nest::where('disabled', '=', false)->get(),
+ 'minimum_credits' => Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
]);
}
@@ -52,7 +53,7 @@ class ServerController extends Controller
"description" => "nullable|max:191",
"node_id" => "required|exists:nodes,id",
"egg_id" => "required|exists:eggs,id",
- "product_id" => "required|exists:products,id",
+ "product_id" => "required|exists:products,id"
]);
//get required resources
@@ -74,8 +75,8 @@ 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()){
+ if (Configuration::getValueByKey('SERVER_CREATE_CHARGE_FIRST_HOUR', 'true') == 'true') {
+ if (Auth::user()->credits >= $server->product->getHourlyPrice()) {
Auth::user()->decrement('credits', $server->product->getHourlyPrice());
}
}
@@ -86,15 +87,26 @@ class ServerController extends Controller
/**
* @return null|RedirectResponse
*/
- private function validateConfigurationRules(){
+ private function validateConfigurationRules()
+ {
//limit validation
if (Auth::user()->servers()->count() >= Auth::user()->server_limit) {
return redirect()->route('servers.index')->with('error', 'Server limit reached!');
}
- //minimum credits
- if (Auth::user()->credits <= Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
- return redirect()->route('servers.index')->with('error', "You do not have the required amount of ".CREDITS_DISPLAY_NAME." to create a new server!");
+ // minimum credits
+ if (FacadesRequest::has("product_id")) {
+ $product = Product::findOrFail(FacadesRequest::input("product_id"));
+ if (
+ Auth::user()->credits <=
+ ($product->minimum_credits == -1
+ ? Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
+ : $product->minimum_credits)
+ ) {
+ return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to create a new server!");
+ }
+ } else if (Auth::user()->credits <= Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
+ return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to create a new server!");
}
//Required Verification for creating an server
@@ -141,7 +153,7 @@ class ServerController extends Controller
* @param Server $server
* @return RedirectResponse
*/
- private function serverCreationFailed(Response $response , Server $server)
+ private function serverCreationFailed(Response $response, Server $server)
{
$server->delete();
diff --git a/app/Models/Product.php b/app/Models/Product.php
index 68dc8f74..f1725da3 100644
--- a/app/Models/Product.php
+++ b/app/Models/Product.php
@@ -6,7 +6,6 @@ use Hidehalo\Nanoid\Client;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Activitylog\Traits\LogsActivity;
class Product extends Model
@@ -17,10 +16,11 @@ class Product extends Model
protected $guarded = ['id'];
- public static function boot() {
+ public static function boot()
+ {
parent::boot();
- static::creating(function(Product $product) {
+ static::creating(function (Product $product) {
$client = new Client();
$product->{$product->getKeyName()} = $client->generateId($size = 21);
@@ -47,6 +47,6 @@ class Product extends Model
*/
public function servers(): BelongsTo
{
- return $this->belongsTo(Server::class , 'id' , 'product_id');
+ return $this->belongsTo(Server::class, 'id', 'product_id');
}
}
diff --git a/database/migrations/2021_10_01_200844_add_product_minimum_credits.php b/database/migrations/2021_10_01_200844_add_product_minimum_credits.php
new file mode 100644
index 00000000..162b52e8
--- /dev/null
+++ b/database/migrations/2021_10_01_200844_add_product_minimum_credits.php
@@ -0,0 +1,32 @@
+float('minimum_credits')->default(-1);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('products', function (Blueprint $table) {
+ $table->dropColumn('minimum_credits');
+ });
+ }
+}
diff --git a/resources/views/admin/products/create.blade.php b/resources/views/admin/products/create.blade.php
index 96935a55..b7d43aad 100644
--- a/resources/views/admin/products/create.blade.php
+++ b/resources/views/admin/products/create.blade.php
@@ -10,9 +10,10 @@
@@ -29,12 +30,16 @@
-
- {{$product->price}}
-
+
+ {{ $product->price }}
+
+
+
+
+
+
+
+
+ Minimum {{ CREDITS_DISPLAY_NAME }}
+
+
+
+ @if ($product->minimum_credits == -1)
+ {{ $minimum_credits }}
+ @else
+ {{ $product->minimum_credits }}
+ @endif
+
@@ -87,9 +108,9 @@
Memory
-
- {{$product->memory}}
-
+
+ {{ $product->memory }}
+
@@ -100,9 +121,9 @@
CPU
-
- {{$product->cpu}}
-
+
+ {{ $product->cpu }}
+
@@ -113,9 +134,9 @@
Swap
-
- {{$product->swap}}
-
+
+ {{ $product->swap }}
+
@@ -126,9 +147,9 @@
Disk
-
- {{$product->disk}}
-
+
+ {{ $product->disk }}
+
@@ -139,9 +160,9 @@
IO
-
- {{$product->io}}
-
+
+ {{ $product->io }}
+
@@ -152,9 +173,9 @@
Databases
-
- {{$product->databases}}
-
+
+ {{ $product->databases }}
+
@@ -165,9 +186,9 @@
Allocations
-
- {{$product->allocations}}
-
+
+ {{ $product->allocations }}
+
@@ -178,9 +199,9 @@
Created At
-
- {{$product->created_at ? $product->created_at->diffForHumans() : ''}}
-
+
+ {{ $product->created_at ? $product->created_at->diffForHumans() : '' }}
+
@@ -192,9 +213,9 @@
Description
-
- {{$product->description}}
-
+
+ {{ $product->description }}
+
@@ -206,9 +227,9 @@
Updated At
-
- {{$product->updated_at ? $product->updated_at->diffForHumans() : ''}}
-
+
+ {{ $product->updated_at ? $product->updated_at->diffForHumans() : '' }}
+
diff --git a/resources/views/servers/create.blade.php b/resources/views/servers/create.blade.php
index 2427a46a..e2918267 100644
--- a/resources/views/servers/create.blade.php
+++ b/resources/views/servers/create.blade.php
@@ -10,9 +10,10 @@
@@ -32,29 +33,29 @@
Create Server
-
+
@csrf
@@ -63,13 +64,13 @@
+ class="custom-select @error('node_id') is-invalid @enderror">
- @foreach($locations as $location)
-
- @foreach($location->nodes as $node)
- @if(!$node->disabled)
- {{$node->name}}
+ @foreach ($locations as $location)
+
+ @foreach ($location->nodes as $node)
+ @if (!$node->disabled)
+ {{ $node->name }}
@endif
@endforeach
@@ -79,20 +80,20 @@
@error('node_id')
-
- Please fill out this field.
-
+
+ Please fill out this field.
+
@enderror
-
From 76d7710d0ec617b805ae9ca38d5cf8c9ffe75175 Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Sat, 2 Oct 2021 18:29:32 +0200
Subject: [PATCH 24/66] Add form data casts for numbers
---
app/Models/User.php | 3 ++-
app/Models/Voucher.php | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/app/Models/User.php b/app/Models/User.php
index 33501ba0..d7c072da 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -81,6 +81,8 @@ class User extends Authenticatable implements MustVerifyEmail
protected $casts = [
'email_verified_at' => 'datetime',
'last_seen' => 'datetime',
+ 'credits' => 'float',
+ 'server_limit' => 'float',
];
/**
@@ -239,5 +241,4 @@ class User extends Authenticatable implements MustVerifyEmail
$status = str_replace(' ', '/', $status);
return $status;
}
-
}
diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php
index bff3e215..81fe635a 100644
--- a/app/Models/Voucher.php
+++ b/app/Models/Voucher.php
@@ -31,7 +31,17 @@ class Voucher extends Model
'expires_at'
];
- protected $appends = ['used' , 'status'];
+ /**
+ * The attributes that should be cast to native types.
+ *
+ * @var array
+ */
+ protected $casts = [
+ 'credits' => 'float',
+ 'uses' => 'integer'
+ ];
+
+ protected $appends = ['used', 'status'];
/**
* @return int
@@ -44,7 +54,8 @@ class Voucher extends Model
/**
* @return string
*/
- public function getStatusAttribute(){
+ public function getStatusAttribute()
+ {
return $this->getStatus();
}
From 6be22c0eeaabd4ab43d08ca17a2de9fbf8d850d6 Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Sun, 3 Oct 2021 00:55:10 +0200
Subject: [PATCH 25/66] Add voucher users
---
.../Controllers/Admin/VoucherController.php | 30 ++-
resources/views/admin/vouchers/show.blade.php | 240 ------------------
.../views/admin/vouchers/users.blade.php | 93 +++++++
routes/web.php | 2 +
4 files changed, 123 insertions(+), 242 deletions(-)
delete mode 100644 resources/views/admin/vouchers/show.blade.php
create mode 100644 resources/views/admin/vouchers/users.blade.php
diff --git a/app/Http/Controllers/Admin/VoucherController.php b/app/Http/Controllers/Admin/VoucherController.php
index 1aa2c59e..31947dbd 100644
--- a/app/Http/Controllers/Admin/VoucherController.php
+++ b/app/Http/Controllers/Admin/VoucherController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Events\UserUpdateCreditsEvent;
use App\Http\Controllers\Controller;
+use App\Models\User;
use App\Models\Voucher;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
@@ -115,6 +116,13 @@ class VoucherController extends Controller
return redirect()->back()->with('success', 'voucher has been removed!');
}
+ public function users(Voucher $voucher)
+ {
+ return view('admin.vouchers.users', [
+ 'voucher' => $voucher
+ ]);
+ }
+
/**
* @param Request $request
* @return JsonResponse
@@ -144,7 +152,7 @@ class VoucherController extends Controller
]);
if ($request->user()->credits + $voucher->credits >= 99999999) throw ValidationException::withMessages([
- 'code' => "You can't redeem this voucher because you would exceed the ".CREDITS_DISPLAY_NAME." limit"
+ 'code' => "You can't redeem this voucher because you would exceed the " . CREDITS_DISPLAY_NAME . " limit"
]);
#redeem voucher
@@ -153,10 +161,27 @@ class VoucherController extends Controller
event(new UserUpdateCreditsEvent($request->user()));
return response()->json([
- 'success' => "{$voucher->credits} ".CREDITS_DISPLAY_NAME." have been added to your balance!"
+ 'success' => "{$voucher->credits} " . CREDITS_DISPLAY_NAME . " have been added to your balance!"
]);
}
+ public function usersDataTable(Voucher $voucher)
+ {
+ $users = $voucher->users();
+
+ return datatables($users)
+ ->editColumn('name', function (User $user) {
+ return '' . $user->name . ' ';
+ })
+ ->addColumn('credits', function (User $user) {
+ return ' ' . $user->credits();
+ })
+ ->addColumn('last_seen', function (User $user) {
+ return $user->last_seen ? $user->last_seen->diffForHumans() : '';
+ })
+ ->rawColumns(['name', 'credits', 'last_seen'])
+ ->make();
+ }
public function dataTable()
{
$query = Voucher::query();
@@ -164,6 +189,7 @@ class VoucherController extends Controller
return datatables($query)
->addColumn('actions', function (Voucher $voucher) {
return '
+
diff --git a/resources/views/admin/vouchers/show.blade.php b/resources/views/admin/vouchers/show.blade.php
deleted file mode 100644
index 46d13b5d..00000000
--- a/resources/views/admin/vouchers/show.blade.php
+++ /dev/null
@@ -1,240 +0,0 @@
-@extends('layouts.main')
-
-@section('content')
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ID
-
-
-
- {{$product->id}}
-
-
-
-
-
-
-
-
- Name
-
-
-
- {{$product->name}}
-
-
-
-
-
-
-
-
- Price
-
-
-
- {{$product->price}}
-
-
-
-
-
-
-
-
-
- Memory
-
-
-
- {{$product->memory}}
-
-
-
-
-
-
-
-
- CPU
-
-
-
- {{$product->cpu}}
-
-
-
-
-
-
-
-
- Swap
-
-
-
- {{$product->swap}}
-
-
-
-
-
-
-
-
- Disk
-
-
-
- {{$product->disk}}
-
-
-
-
-
-
-
-
- IO
-
-
-
- {{$product->io}}
-
-
-
-
-
-
-
-
- Databases
-
-
-
- {{$product->databases}}
-
-
-
-
-
-
-
-
- Allocations
-
-
-
- {{$product->allocations}}
-
-
-
-
-
-
-
-
- Created At
-
-
-
- {{$product->created_at ? $product->created_at->diffForHumans() : ''}}
-
-
-
-
-
-
-
-
-
- Description
-
-
-
- {{$product->description}}
-
-
-
-
-
-
-
-
-
- Updated At
-
-
-
- {{$product->updated_at ? $product->updated_at->diffForHumans() : ''}}
-
-
-
-
-
-
-
-
-
-
-
-
-
- @include('admin.servers.table' , ['filter' => '?product=' . $product->id])
-
-
-
-
-
-
-
-
-
-
-
-
-
-@endsection
diff --git a/resources/views/admin/vouchers/users.blade.php b/resources/views/admin/vouchers/users.blade.php
new file mode 100644
index 00000000..bb5ed322
--- /dev/null
+++ b/resources/views/admin/vouchers/users.blade.php
@@ -0,0 +1,93 @@
+@extends('layouts.main')
+
+@section('content')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID
+ Name
+ Email
+ {{ CREDITS_DISPLAY_NAME }}
+ Last Seen
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index 33bdf1df..ae1fa78a 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -119,6 +119,8 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::resource('usefullinks', UsefulLinkController::class);
Route::get('vouchers/datatable', [VoucherController::class, 'datatable'])->name('vouchers.datatable');
+ Route::get('vouchers/{voucher}/usersdatatable', [VoucherController::class, 'usersdatatable'])->name('vouchers.usersdatatable');
+ Route::get('vouchers/{voucher}/users', [VoucherController::class, 'users'])->name('vouchers.users');
Route::resource('vouchers', VoucherController::class);
Route::get('api/datatable', [ApplicationApiController::class, 'datatable'])->name('api.datatable');
From 7d229ec25bb8bdd1a259636d239945370fb5d15f Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Sun, 3 Oct 2021 14:47:51 +0200
Subject: [PATCH 26/66] Remove the global check for minimum required credits
---
app/Http/Controllers/ServerController.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index 2709c3a3..84749ab6 100644
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -103,10 +103,8 @@ class ServerController extends Controller
? Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
: $product->minimum_credits)
) {
- return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to create a new server!");
+ return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to use this product!");
}
- } else if (Auth::user()->credits <= Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)) {
- return redirect()->route('servers.index')->with('error', "You do not have the required amount of " . CREDITS_DISPLAY_NAME . " to create a new server!");
}
//Required Verification for creating an server
From 4d3c6c7a13049f2d7f8db9ffb1e267f347eb666b Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Sun, 3 Oct 2021 15:18:08 +0200
Subject: [PATCH 27/66] Fix select if using global limit
---
app/Http/Controllers/ServerController.php | 3 ++-
resources/views/servers/create.blade.php | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index 84749ab6..d1c260cd 100644
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -16,6 +16,7 @@ use Illuminate\Http\Client\Response;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Request as FacadesRequest;
class ServerController extends Controller
@@ -98,7 +99,7 @@ class ServerController extends Controller
if (FacadesRequest::has("product_id")) {
$product = Product::findOrFail(FacadesRequest::input("product_id"));
if (
- Auth::user()->credits <=
+ Auth::user()->credits <
($product->minimum_credits == -1
? Configuration::getValueByKey('MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50)
: $product->minimum_credits)
diff --git a/resources/views/servers/create.blade.php b/resources/views/servers/create.blade.php
index e2918267..50e3d1a5 100644
--- a/resources/views/servers/create.blade.php
+++ b/resources/views/servers/create.blade.php
@@ -113,7 +113,8 @@
class="custom-select @error('product_id') is-invalid @enderror">
@foreach ($products as $product)
minimum_credits == -1 && Auth::user()->credits >= $minimum_credits)
- @elseif (Auth::user()->credits >= $product->minimum_credits)
+ @elseif ($product->minimum_credits != -1 && Auth::user()->credits >=
+ $product->minimum_credits)
@else
disabled
@endif
From 4bc9d4cdceba0a69f6e66494ea2cccdfb409c8ce Mon Sep 17 00:00:00 2001
From: Jovan Jovanovic
Date: Sun, 3 Oct 2021 21:28:34 +0200
Subject: [PATCH 28/66] Fix tooltips
---
resources/views/admin/products/create.blade.php | 7 ++++++-
resources/views/admin/products/edit.blade.php | 11 ++++++++---
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/resources/views/admin/products/create.blade.php b/resources/views/admin/products/create.blade.php
index b7d43aad..8b7ed49f 100644
--- a/resources/views/admin/products/create.blade.php
+++ b/resources/views/admin/products/create.blade.php
@@ -136,7 +136,7 @@
@@ -37,16 +36,26 @@
Save
-