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') - -
-
-
-
-

Products

-
-
- -
-
-
-
- - - -
-
- -
-
-
Product
-
- - - {{ csrf_field() }} - {{ method_field("DELETE") }} - - -
-
-
-
- -
-
-
- -
-
- - {{$product->id}} - -
-
-
- -
-
-
- -
-
- - {{$product->name}} - -
-
-
- -
-
-
- -
-
- - {{$product->price}} - -
-
-
- - -
-
-
- -
-
- - {{$product->memory}} - -
-
-
- -
-
-
- -
-
- - {{$product->cpu}} - -
-
-
- -
-
-
- -
-
- - {{$product->swap}} - -
-
-
- -
-
-
- -
-
- - {{$product->disk}} - -
-
-
- -
-
-
- -
-
- - {{$product->io}} - -
-
-
- -
-
-
- -
-
- - {{$product->databases}} - -
-
-
- -
-
-
- -
-
- - {{$product->allocations}} - -
-
-
- -
-
-
- -
-
- - {{$product->created_at ? $product->created_at->diffForHumans() : ''}} - -
-
-
- - -
-
-
- -
-
- - {{$product->description}} - -
-
-
- - -
-
-
- -
-
- - {{$product->updated_at ? $product->updated_at->diffForHumans() : ''}} - -
-
-
- -
-
-
- -
-
-
Servers
-
-
- - @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') + +
+
+
+
+

Vouchers

+
+
+ +
+
+
+
+ + + +
+
+ +
+ +
+
+
Users
+
+
+ +
+ + + + + + + + + + + + + +
IDNameEmail{{ 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');