Rename PaypalProduct -> CreditProduct

This commit is contained in:
IceToast 2021-12-13 00:58:47 +01:00
parent bd6cec92ea
commit e3b8ff5045
13 changed files with 1609 additions and 951 deletions

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Models\PaypalProduct; use App\Models\CreditProduct;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
@ -12,7 +12,7 @@ use Illuminate\Http\Response;
use Illuminate\Routing\Controller; use Illuminate\Routing\Controller;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
class PaypalProductController extends Controller class CreditProductController extends Controller
{ {
/** /**
* Display a listing of the resource. * Display a listing of the resource.
@ -60,7 +60,7 @@ class PaypalProductController extends Controller
]); ]);
$disabled = !is_null($request->input('disabled')); $disabled = !is_null($request->input('disabled'));
PaypalProduct::create(array_merge($request->all(), ['disabled' => $disabled])); CreditProduct::create(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.store.index')->with('success', 'Store item has been created!'); return redirect()->route('admin.store.index')->with('success', 'Store item has been created!');
} }
@ -68,10 +68,10 @@ class PaypalProductController extends Controller
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return Response * @return Response
*/ */
public function show(PaypalProduct $paypalProduct) public function show(CreditProduct $creditProduct)
{ {
// //
} }
@ -79,14 +79,14 @@ class PaypalProductController extends Controller
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return Application|Factory|View|Response * @return Application|Factory|View|Response
*/ */
public function edit(PaypalProduct $paypalProduct) public function edit(CreditProduct $creditProduct)
{ {
return view('admin.store.edit', [ return view('admin.store.edit', [
'currencyCodes' => config('currency_codes'), 'currencyCodes' => config('currency_codes'),
'paypalProduct' => $paypalProduct 'creditProduct' => $creditProduct
]); ]);
} }
@ -94,10 +94,10 @@ class PaypalProductController extends Controller
* Update the specified resource in storage. * Update the specified resource in storage.
* *
* @param Request $request * @param Request $request
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return RedirectResponse * @return RedirectResponse
*/ */
public function update(Request $request, PaypalProduct $paypalProduct) public function update(Request $request, CreditProduct $creditProduct)
{ {
$request->validate([ $request->validate([
"disabled" => "nullable", "disabled" => "nullable",
@ -110,19 +110,19 @@ class PaypalProductController extends Controller
]); ]);
$disabled = !is_null($request->input('disabled')); $disabled = !is_null($request->input('disabled'));
$paypalProduct->update(array_merge($request->all(), ['disabled' => $disabled])); $creditProduct->update(array_merge($request->all(), ['disabled' => $disabled]));
return redirect()->route('admin.store.index')->with('success', 'Store item has been updated!'); return redirect()->route('admin.store.index')->with('success', 'Store item has been updated!');
} }
/** /**
* @param Request $request * @param Request $request
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return RedirectResponse * @return RedirectResponse
*/ */
public function disable(Request $request, PaypalProduct $paypalProduct) public function disable(Request $request, CreditProduct $creditProduct)
{ {
$paypalProduct->update(['disabled' => !$paypalProduct->disabled]); $creditProduct->update(['disabled' => !$creditProduct->disabled]);
return redirect()->route('admin.store.index')->with('success', 'Product has been updated!'); return redirect()->route('admin.store.index')->with('success', 'Product has been updated!');
} }
@ -130,50 +130,50 @@ class PaypalProductController extends Controller
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return RedirectResponse * @return RedirectResponse
*/ */
public function destroy(PaypalProduct $paypalProduct) public function destroy(CreditProduct $creditProduct)
{ {
$paypalProduct->delete(); $creditProduct->delete();
return redirect()->back()->with('success', 'Store item has been removed!'); return redirect()->back()->with('success', 'Store item has been removed!');
} }
public function dataTable() public function dataTable()
{ {
$query = PaypalProduct::query(); $query = CreditProduct::query();
return datatables($query) return datatables($query)
->addColumn('actions', function (PaypalProduct $paypalProduct) { ->addColumn('actions', function (CreditProduct $creditProduct) {
return ' return '
<a data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.store.edit', $paypalProduct->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a> <a data-content="Edit" data-toggle="popover" data-trigger="hover" data-placement="top" href="' . route('admin.store.edit', $creditProduct->id) . '" class="btn btn-sm btn-info mr-1"><i class="fas fa-pen"></i></a>
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.destroy', $paypalProduct->id) . '"> <form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.destroy', $creditProduct->id) . '">
' . csrf_field() . ' ' . csrf_field() . '
' . method_field("DELETE") . ' ' . method_field("DELETE") . '
<button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button> <button data-content="Delete" data-toggle="popover" data-trigger="hover" data-placement="top" class="btn btn-sm btn-danger mr-1"><i class="fas fa-trash"></i></button>
</form> </form>
'; ';
}) })
->addColumn('disabled', function (PaypalProduct $paypalProduct) { ->addColumn('disabled', function (CreditProduct $creditProduct) {
$checked = $paypalProduct->disabled == false ? "checked" : ""; $checked = $creditProduct->disabled == false ? "checked" : "";
return ' return '
<form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.disable', $paypalProduct->id) . '"> <form class="d-inline" onsubmit="return submitResult();" method="post" action="' . route('admin.store.disable', $creditProduct->id) . '">
' . csrf_field() . ' ' . csrf_field() . '
' . method_field("PATCH") . ' ' . method_field("PATCH") . '
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input ' . $checked . ' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch' . $paypalProduct->id . '"> <input ' . $checked . ' name="disabled" onchange="this.form.submit()" type="checkbox" class="custom-control-input" id="switch' . $creditProduct->id . '">
<label class="custom-control-label" for="switch' . $paypalProduct->id . '"></label> <label class="custom-control-label" for="switch' . $creditProduct->id . '"></label>
</div> </div>
</form> </form>
'; ';
}) })
->editColumn('created_at', function (PaypalProduct $paypalProduct) { ->editColumn('created_at', function (CreditProduct $creditProduct) {
return $paypalProduct->created_at ? $paypalProduct->created_at->diffForHumans() : ''; return $creditProduct->created_at ? $creditProduct->created_at->diffForHumans() : '';
}) })
->editColumn('price', function (PaypalProduct $paypalProduct) { ->editColumn('price', function (CreditProduct $creditProduct) {
return $paypalProduct->formatToCurrency($paypalProduct->price); return $creditProduct->formatToCurrency($creditProduct->price);
}) })
->rawColumns(['actions', 'disabled']) ->rawColumns(['actions', 'disabled'])
->make(); ->make();

View file

@ -6,7 +6,7 @@ use App\Events\UserUpdateCreditsEvent;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Configuration; use App\Models\Configuration;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaypalProduct; use App\Models\CreditProduct;
use App\Models\Product; use App\Models\Product;
use App\Models\User; use App\Models\User;
use App\Notifications\ConfirmPaymentNotification; use App\Notifications\ConfirmPaymentNotification;
@ -40,25 +40,25 @@ class PaymentController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return Application|Factory|View * @return Application|Factory|View
*/ */
public function checkOut(Request $request, PaypalProduct $paypalProduct) public function checkOut(Request $request, CreditProduct $creditProduct)
{ {
return view('store.checkout')->with([ return view('store.checkout')->with([
'product' => $paypalProduct, 'product' => $creditProduct,
'taxvalue' => $paypalProduct->getTaxValue(), 'taxvalue' => $creditProduct->getTaxValue(),
'taxpercent' => $paypalProduct->getTaxPercent(), 'taxpercent' => $creditProduct->getTaxPercent(),
'total' => $paypalProduct->getTotalPrice() 'total' => $creditProduct->getTotalPrice()
]); ]);
} }
/** /**
* @param Request $request * @param Request $request
* @param PaypalProduct $paypalProduct * @param CreditProduct $creditProduct
* @return RedirectResponse * @return RedirectResponse
*/ */
public function pay(Request $request, PaypalProduct $paypalProduct) public function pay(Request $request, CreditProduct $creditProduct)
{ {
$request = new OrdersCreateRequest(); $request = new OrdersCreateRequest();
$request->prefer('return=representation'); $request->prefer('return=representation');
@ -67,33 +67,33 @@ class PaymentController extends Controller
"purchase_units" => [ "purchase_units" => [
[ [
"reference_id" => uniqid(), "reference_id" => uniqid(),
"description" => $paypalProduct->description, "description" => $creditProduct->description,
"amount" => [ "amount" => [
"value" => $paypalProduct->getTotalPrice(), "value" => $creditProduct->getTotalPrice(),
'currency_code' => strtoupper($paypalProduct->currency_code), 'currency_code' => strtoupper($creditProduct->currency_code),
'breakdown' =>[ 'breakdown' =>[
'item_total' => 'item_total' =>
[ [
'currency_code' => strtoupper($paypalProduct->currency_code), 'currency_code' => strtoupper($creditProduct->currency_code),
'value' => $paypalProduct->price, 'value' => $creditProduct->price,
], ],
'tax_total' => 'tax_total' =>
[ [
'currency_code' => strtoupper($paypalProduct->currency_code), 'currency_code' => strtoupper($creditProduct->currency_code),
'value' => $paypalProduct->getTaxValue(), 'value' => $creditProduct->getTaxValue(),
] ]
] ]
] ]
] ]
], ],
"application_context" => [ "application_context" => [
"cancel_url" => route('payment.cancel'), "cancel_url" => route('payment.PaypalCancel'),
"return_url" => route('payment.success', ['product' => $paypalProduct->id]), "return_url" => route('payment.PaypalSuccess', ['product' => $creditProduct->id]),
'brand_name' => config('app.name', 'Laravel'), 'brand_name' => config('app.name', 'Laravel'),
'shipping_preference' => 'NO_SHIPPING' 'shipping_preference' => 'NO_SHIPPING'
] ]
]; ];
@ -116,8 +116,8 @@ class PaymentController extends Controller
protected function getPayPalClient() protected function getPayPalClient()
{ {
$environment = env('APP_ENV') == 'local' $environment = env('APP_ENV') == 'local'
? new SandboxEnvironment($this->getClientId(), $this->getClientSecret()) ? new SandboxEnvironment($this->getPaypalClientId(), $this->getPaypalClientSecret())
: new ProductionEnvironment($this->getClientId(), $this->getClientSecret()); : new ProductionEnvironment($this->getPaypalClientId(), $this->getPaypalClientSecret());
return new PayPalHttpClient($environment); return new PayPalHttpClient($environment);
} }
@ -125,7 +125,7 @@ class PaymentController extends Controller
/** /**
* @return string * @return string
*/ */
protected function getClientId() protected function getPaypalClientId()
{ {
return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID'); return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID');
} }
@ -133,7 +133,7 @@ class PaymentController extends Controller
/** /**
* @return string * @return string
*/ */
protected function getClientSecret() protected function getPaypalClientSecret()
{ {
return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_SECRET') : env('PAYPAL_SECRET'); return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_SECRET') : env('PAYPAL_SECRET');
} }
@ -141,10 +141,10 @@ class PaymentController extends Controller
/** /**
* @param Request $laravelRequest * @param Request $laravelRequest
*/ */
public function success(Request $laravelRequest) public function PaypalSuccess(Request $laravelRequest)
{ {
/** @var PaypalProduct $paypalProduct */ /** @var CreditProduct $creditProduct */
$paypalProduct = PaypalProduct::findOrFail($laravelRequest->input('product')); $creditProduct = CreditProduct::findOrFail($laravelRequest->input('product'));
/** @var User $user */ /** @var User $user */
$user = Auth::user(); $user = Auth::user();
@ -156,7 +156,7 @@ class PaymentController extends Controller
if ($response->statusCode == 201 || $response->statusCode == 200) { if ($response->statusCode == 201 || $response->statusCode == 200) {
//update credits //update credits
$user->increment('credits', $paypalProduct->quantity); $user->increment('credits', $creditProduct->quantity);
//update server limit //update server limit
if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { if (Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
@ -164,7 +164,7 @@ class PaymentController extends Controller
$user->update(['server_limit' => Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')]); $user->update(['server_limit' => Configuration::getValueByKey('SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
} }
} }
//update role //update role
if ($user->role == 'member') { if ($user->role == 'member') {
$user->update(['role' => 'client']); $user->update(['role' => 'client']);
@ -177,12 +177,12 @@ class PaymentController extends Controller
'payer_id' => $laravelRequest->input('PayerID'), 'payer_id' => $laravelRequest->input('PayerID'),
'type' => 'Credits', 'type' => 'Credits',
'status' => $response->result->status, 'status' => $response->result->status,
'amount' => $paypalProduct->quantity, 'amount' => $creditProduct->quantity,
'price' => $paypalProduct->price, 'price' => $creditProduct->price,
'tax_value' => $paypalProduct->getTaxValue(), 'tax_value' => $creditProduct->getTaxValue(),
'tax_percent' => $paypalProduct->getTaxPercent(), 'tax_percent' => $creditProduct->getTaxPercent(),
'total_price' => $paypalProduct->getTotalPrice(), 'total_price' => $creditProduct->getTotalPrice(),
'currency_code' => $paypalProduct->currency_code, 'currency_code' => $creditProduct->currency_code,
'payer' => json_encode($response->result->payer), 'payer' => json_encode($response->result->payer),
]); ]);
@ -218,7 +218,7 @@ class PaymentController extends Controller
/** /**
* @param Request $request * @param Request $request
*/ */
public function cancel(Request $request) public function PaypalCancel(Request $request)
{ {
return redirect()->route('store.index')->with('success', 'Payment was Canceled'); return redirect()->route('store.index')->with('success', 'Payment was Canceled');
} }

View file

@ -3,7 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Configuration; use App\Models\Configuration;
use App\Models\PaypalProduct; use App\Models\CreditProduct;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
class StoreController extends Controller class StoreController extends Controller
@ -27,7 +27,7 @@ class StoreController extends Controller
} }
return view('store.index')->with([ return view('store.index')->with([
'products' => PaypalProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(), 'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
'isPaypalSetup' => $isPaypalSetup 'isPaypalSetup' => $isPaypalSetup
]); ]);
} }

View file

@ -8,7 +8,7 @@ use NumberFormatter;
use Spatie\Activitylog\Traits\LogsActivity; use Spatie\Activitylog\Traits\LogsActivity;
use App\Models\Configuration; use App\Models\Configuration;
class PaypalProduct extends Model class CreditProduct extends Model
{ {
use LogsActivity; use LogsActivity;
/** /**
@ -33,17 +33,17 @@ class PaypalProduct extends Model
{ {
parent::boot(); parent::boot();
static::creating(function (PaypalProduct $paypalProduct) { static::creating(function (CreditProduct $creditProduct) {
$client = new Client(); $client = new Client();
$paypalProduct->{$paypalProduct->getKeyName()} = $client->generateId($size = 21); $creditProduct->{$creditProduct->getKeyName()} = $client->generateId($size = 21);
}); });
} }
/** /**
* @param mixed $value * @param mixed $value
* @param string $locale * @param string $locale
* *
* @return float * @return float
*/ */
public function formatToCurrency($value,$locale = 'en_US') public function formatToCurrency($value,$locale = 'en_US')
@ -78,7 +78,7 @@ class PaypalProduct extends Model
* *
* @return float * @return float
*/ */
public function getTotalPrice() public function getTotalPrice()
{ {
return $this->price+($this->getTaxValue()); return $this->price+($this->getTaxValue());
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "laravel/laravel", "name": "controlpanelgg",
"type": "project", "type": "project",
"description": "The Laravel Framework.", "description": "A billing and control panel made for Pterodactyl.",
"keywords": [ "keywords": [
"framework", "framework",
"laravel" "laravel"
@ -25,6 +25,7 @@
"spatie/laravel-activitylog": "^3.16", "spatie/laravel-activitylog": "^3.16",
"spatie/laravel-query-builder": "^3.6", "spatie/laravel-query-builder": "^3.6",
"spatie/laravel-validation-rules": "^3.0", "spatie/laravel-validation-rules": "^3.0",
"stripe/stripe-php": "^7.107",
"yajra/laravel-datatables-oracle": "~9.0" "yajra/laravel-datatables-oracle": "~9.0"
}, },
"require-dev": { "require-dev": {

2301
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class CreatePaypalProductsTable extends Migration class CreateCreditProductsTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
@ -13,7 +13,7 @@ class CreatePaypalProductsTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('paypal_products', function (Blueprint $table) { Schema::create('credit_products', function (Blueprint $table) {
$table->uuid('id')->primary(); $table->uuid('id')->primary();
$table->string('type'); $table->string('type');
$table->decimal('price')->default(0); $table->decimal('price')->default(0);
@ -32,6 +32,6 @@ class CreatePaypalProductsTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('paypal_products'); Schema::dropIfExists('credit_products');
} }
} }

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class AddDisplayToPaypalProductsTable extends Migration class AddDisplayToCreditProductsTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
@ -13,7 +13,7 @@ class AddDisplayToPaypalProductsTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::table('paypal_products', function (Blueprint $table) { Schema::table('credit_products', function (Blueprint $table) {
$table->string('display'); $table->string('display');
}); });
} }
@ -25,7 +25,7 @@ class AddDisplayToPaypalProductsTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::table('paypal_products', function (Blueprint $table) { Schema::table('credit_products', function (Blueprint $table) {
$table->dropColumn('display'); $table->dropColumn('display');
}); });
} }

View file

@ -3,7 +3,7 @@
namespace Database\Seeders; namespace Database\Seeders;
use Database\Seeders\Seeds\ProductSeeder; use Database\Seeders\Seeds\ProductSeeder;
use Database\Seeders\Seeds\PaypalProductSeeder; use Database\Seeders\Seeds\CreditProductSeeder;
use Database\Seeders\Seeds\ApplicationApiSeeder; use Database\Seeders\Seeds\ApplicationApiSeeder;
use Database\Seeders\Seeds\UsefulLinksSeeder; use Database\Seeders\Seeds\UsefulLinksSeeder;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -19,7 +19,7 @@ class ExampleItemsSeeder extends Seeder
{ {
$this->call([ $this->call([
ProductSeeder::class, ProductSeeder::class,
PaypalProductSeeder::class, CreditProductSeeder::class,
ApplicationApiSeeder::class, ApplicationApiSeeder::class,
UsefulLinksSeeder::class UsefulLinksSeeder::class
]); ]);

View file

@ -2,10 +2,10 @@
namespace Database\Seeders\Seeds; namespace Database\Seeders\Seeds;
use App\Models\PaypalProduct; use App\Models\CreditProduct;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class PaypalProductSeeder extends Seeder class CreditProductSeeder extends Seeder
{ {
/** /**
* Run the database seeds. * Run the database seeds.
@ -14,7 +14,7 @@ class PaypalProductSeeder extends Seeder
*/ */
public function run() public function run()
{ {
PaypalProduct::create([ CreditProduct::create([
'type' => 'Credits', 'type' => 'Credits',
'display' => '350', 'display' => '350',
'description' => 'Adds 350 credits to your account', 'description' => 'Adds 350 credits to your account',
@ -24,7 +24,7 @@ class PaypalProductSeeder extends Seeder
'disabled' => false, 'disabled' => false,
]); ]);
PaypalProduct::create([ CreditProduct::create([
'type' => 'Credits', 'type' => 'Credits',
'display' => '875 + 125', 'display' => '875 + 125',
'description' => 'Adds 1000 credits to your account', 'description' => 'Adds 1000 credits to your account',
@ -34,7 +34,7 @@ class PaypalProductSeeder extends Seeder
'disabled' => false, 'disabled' => false,
]); ]);
PaypalProduct::create([ CreditProduct::create([
'type' => 'Credits', 'type' => 'Credits',
'display' => '1750 + 250', 'display' => '1750 + 250',
'description' => 'Adds 2000 credits to your account', 'description' => 'Adds 2000 credits to your account',
@ -44,7 +44,7 @@ class PaypalProductSeeder extends Seeder
'disabled' => false, 'disabled' => false,
]); ]);
PaypalProduct::create([ CreditProduct::create([
'type' => 'Credits', 'type' => 'Credits',
'display' => '3500 + 500', 'display' => '3500 + 500',
'description' => 'Adds 4000 credits to your account', 'description' => 'Adds 4000 credits to your account',

View file

@ -12,7 +12,7 @@
<ol class="breadcrumb float-sm-right"> <ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{route('home')}}">Dashboard</a></li> <li class="breadcrumb-item"><a href="{{route('home')}}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{{route('admin.store.index')}}">Store</a></li> <li class="breadcrumb-item"><a href="{{route('admin.store.index')}}">Store</a></li>
<li class="breadcrumb-item"><a class="text-muted" href="{{route('admin.store.edit' , $paypalProduct->id)}}">Edit</a> <li class="breadcrumb-item"><a class="text-muted" href="{{route('admin.store.edit' , $creditProduct->id)}}">Edit</a>
</li> </li>
</ol> </ol>
</div> </div>
@ -29,12 +29,12 @@
<div class="col-lg-6"> <div class="col-lg-6">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<form action="{{route('admin.store.update' , $paypalProduct->id)}}" method="POST"> <form action="{{route('admin.store.update' , $creditProduct->id)}}" method="POST">
@csrf @csrf
@method('PATCH') @method('PATCH')
<div class="d-flex flex-row-reverse"> <div class="d-flex flex-row-reverse">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input type="checkbox" @if($paypalProduct->disabled) checked @endif name="disabled" class="custom-control-input custom-control-input-danger" <input type="checkbox" @if($creditProduct->disabled) checked @endif name="disabled" class="custom-control-input custom-control-input-danger"
id="switch1"> id="switch1">
<label class="custom-control-label" for="switch1">Disabled <i data-toggle="popover" <label class="custom-control-label" for="switch1">Disabled <i data-toggle="popover"
data-trigger="hover" data-trigger="hover"
@ -59,7 +59,7 @@
<label for="currency_code">Currency code</label> <label for="currency_code">Currency code</label>
<select required name="currency_code" id="currency_code" class="custom-select @error('name') is-invalid @enderror"> <select required name="currency_code" id="currency_code" class="custom-select @error('name') is-invalid @enderror">
@foreach($currencyCodes as $code) @foreach($currencyCodes as $code)
<option @if($paypalProduct->currency_code == $code) selected @endif value="{{$code}}">{{$code}}</option> <option @if($creditProduct->currency_code == $code) selected @endif value="{{$code}}">{{$code}}</option>
@endforeach @endforeach
</select> </select>
@error('currency_code') @error('currency_code')
@ -74,7 +74,7 @@
<div class="form-group"> <div class="form-group">
<label for="price">Price</label> <label for="price">Price</label>
<input value="{{$paypalProduct->price}}" id="price" name="price" <input value="{{$creditProduct->price}}" id="price" name="price"
type="number" type="number"
placeholder="10.00" placeholder="10.00"
step="any" step="any"
@ -89,7 +89,7 @@
<div class="form-group"> <div class="form-group">
<label for="quantity">Quantity</label> <label for="quantity">Quantity</label>
<input value="{{$paypalProduct->quantity}}" id="quantity" name="quantity" <input value="{{$creditProduct->quantity}}" id="quantity" name="quantity"
type="number" type="number"
placeholder="1000" placeholder="1000"
class="form-control @error('quantity') is-invalid @enderror" class="form-control @error('quantity') is-invalid @enderror"
@ -106,7 +106,7 @@
<div class="form-group"> <div class="form-group">
<label for="display">Display</label> <label for="display">Display</label>
<input value="{{$paypalProduct->display}}" id="display" name="display" <input value="{{$creditProduct->display}}" id="display" name="display"
type="text" type="text"
placeholder="750 + 250" placeholder="750 + 250"
class="form-control @error('display') is-invalid @enderror" class="form-control @error('display') is-invalid @enderror"
@ -123,7 +123,7 @@
<div class="form-group"> <div class="form-group">
<label for="description">Description</label> <label for="description">Description</label>
<input value="{{$paypalProduct->description}}" id="description" name="description" <input value="{{$creditProduct->description}}" id="description" name="description"
type="text" type="text"
placeholder="Adds 1000 credits to your account" placeholder="Adds 1000 credits to your account"
class="form-control @error('description') is-invalid @enderror" class="form-control @error('description') is-invalid @enderror"

View file

@ -1,5 +1,5 @@
@extends('layouts.main') @extends('layouts.main')
<?php use App\Models\PaypalProduct; ?> <?php use App\Models\CreditProduct; ?>
@section('content') @section('content')
<!-- CONTENT HEADER --> <!-- CONTENT HEADER -->
@ -11,8 +11,9 @@
</div> </div>
<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="" href="{{route('home')}}">Dashboard</a></li> <li class="breadcrumb-item"><a class="" href="{{ route('home') }}">Dashboard</a></li>
<li class="breadcrumb-item"><a class="text-muted" href="{{route('store.index')}}">Store</a></li> <li class="breadcrumb-item"><a class="text-muted" href="{{ route('store.index') }}">Store</a>
</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -30,33 +31,36 @@
</button> </button>
</div> </div>
@if($isPaypalSetup && $products->count() > 0) @if ($isPaypalSetup && $products->count() > 0)
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h5 class="card-title"><i class="fa fa-coins mr-2"></i>{{CREDITS_DISPLAY_NAME}}</h5> <h5 class="card-title"><i class="fa fa-coins mr-2"></i>{{ CREDITS_DISPLAY_NAME }}</h5>
</div> </div>
<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 PaypalProduct */?> <?php /** @var $product CreditProduct */
@foreach($products as $product) ?>
<tr> @foreach ($products as $product)
<td>{{$product->formatToCurrency($product->price)}}</td> <tr>
<td>{{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}}</td> <td>{{ $product->formatToCurrency($product->price) }}</td>
<td><i class="fa fa-coins mr-2"></i>{{$product->display}}</td> <td>{{ strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type }}
<td><a href="{{route('checkout' , $product->id)}}" class="btn btn-info">Purchase</a> </td>
</td> <td><i class="fa fa-coins mr-2"></i>{{ $product->display }}</td>
</tr> <td><a href="{{ route('checkout', $product->id) }}"
@endforeach class="btn btn-info">Purchase</a>
</td>
</tr>
@endforeach
</tbody> </tbody>
</table> </table>
</div> </div>
@ -65,7 +69,7 @@
@else @else
<div class="alert alert-danger alert-dismissible"> <div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-ban"></i> @if($products->count() == 0) There are no store products! @else The store is not correctly configured! @endif <h4><i class="icon fa fa-ban"></i> @if ($products->count() == 0) There are no store products! @else The store is not correctly configured! @endif
</h4> </h4>
</div> </div>

View file

@ -5,7 +5,7 @@ use App\Http\Controllers\Admin\ApplicationApiController;
use App\Http\Controllers\Admin\ConfigurationController; use App\Http\Controllers\Admin\ConfigurationController;
use App\Http\Controllers\Admin\OverViewController; use App\Http\Controllers\Admin\OverViewController;
use App\Http\Controllers\Admin\PaymentController; use App\Http\Controllers\Admin\PaymentController;
use App\Http\Controllers\Admin\PaypalProductController; use App\Http\Controllers\Admin\CreditProductController;
use App\Http\Controllers\Admin\ProductController; use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\ServerController as AdminServerController; use App\Http\Controllers\Admin\ServerController as AdminServerController;
use App\Http\Controllers\Admin\SettingsController; use App\Http\Controllers\Admin\SettingsController;
@ -61,10 +61,10 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::get('/products/products/{egg?}/{node?}', [FrontProductController::class, 'getProductsBasedOnNode'])->name('products.products.node'); Route::get('/products/products/{egg?}/{node?}', [FrontProductController::class, 'getProductsBasedOnNode'])->name('products.products.node');
#payments #payments
Route::get('checkout/{paypalProduct}', [PaymentController::class, 'checkOut'])->name('checkout'); Route::get('checkout/{creditProduct}', [PaymentController::class, 'checkOut'])->name('checkout');
Route::get('payment/success', [PaymentController::class, 'success'])->name('payment.success'); Route::get('payment/PaypalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess');
Route::get('payment/cancel', [PaymentController::class, 'cancel'])->name('payment.cancel'); Route::get('payment/PaypalCancel', [PaymentController::class, 'PaypalCancel'])->name('payment.PaypalCancel');
Route::get('payment/pay/{paypalProduct}', [PaymentController::class, 'pay'])->name('payment.pay'); Route::get('payment/pay/{creditProduct}', [PaymentController::class, 'pay'])->name('payment.pay');
Route::get('users/logbackin', [UserController::class, 'logBackIn'])->name('users.logbackin'); Route::get('users/logbackin', [UserController::class, 'logBackIn'])->name('users.logbackin');
@ -100,10 +100,10 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::patch('products/disable/{product}', [ProductController::class, 'disable'])->name('products.disable'); Route::patch('products/disable/{product}', [ProductController::class, 'disable'])->name('products.disable');
Route::resource('products', ProductController::class); Route::resource('products', ProductController::class);
Route::get('store/datatable', [PaypalProductController::class, 'datatable'])->name('store.datatable'); Route::get('store/datatable', [CreditProductController::class, 'datatable'])->name('store.datatable');
Route::patch('store/disable/{paypalProduct}', [PaypalProductController::class, 'disable'])->name('store.disable'); Route::patch('store/disable/{creditProduct}', [CreditProductController::class, 'disable'])->name('store.disable');
Route::resource('store', PaypalProductController::class)->parameters([ Route::resource('store', CreditProductController::class)->parameters([
'store' => 'paypalProduct', 'store' => 'creditProduct',
]); ]);
Route::get('payments/datatable', [PaymentController::class, 'datatable'])->name('payments.datatable'); Route::get('payments/datatable', [PaymentController::class, 'datatable'])->name('payments.datatable');