ctrlpanel/app/Http/Controllers/StoreController.php

38 lines
1.4 KiB
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?php
namespace App\Http\Controllers;
2021-06-26 20:04:23 +00:00
use App\Models\Configuration;
2021-12-12 23:58:47 +00:00
use App\Models\CreditProduct;
2021-06-26 20:04:23 +00:00
use Illuminate\Support\Facades\Auth;
2021-06-05 09:26:32 +00:00
class StoreController extends Controller
{
2021-06-06 18:17:52 +00:00
/** Display a listing of the resource. */
2021-06-06 21:26:36 +00:00
public function index()
2021-06-05 09:26:32 +00:00
{
$isPaymentSetup = false;
2021-06-26 20:04:23 +00:00
if (
env('APP_ENV') == 'local' ||
env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') ||
env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')
) $isPaymentSetup = true;
2021-06-26 20:04:23 +00:00
//Required Verification for creating an server
if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
2021-12-13 10:47:35 +00:00
return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits."));
2021-06-26 20:04:23 +00:00
}
//Required Verification for creating an server
if (Configuration::getValueByKey('FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
2021-12-13 10:47:35 +00:00
return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits"));
2021-06-26 20:04:23 +00:00
}
2021-06-05 09:26:32 +00:00
return view('store.index')->with([
2021-12-12 23:58:47 +00:00
'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
'isPaymentSetup' => $isPaymentSetup,
2021-06-05 09:26:32 +00:00
]);
}
}