ctrlpanel/app/Http/Controllers/StoreController.php

39 lines
1.5 KiB
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?php
namespace App\Http\Controllers;
2022-05-30 09:07:10 +00:00
use App\Models\ShopProduct;
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. */
public function index()
2021-06-05 09:26:32 +00:00
{
$isPaymentSetup = false;
if (
env('APP_ENV') == 'local' ||
config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
) {
$isPaymentSetup = true;
}
2021-06-26 20:04:23 +00:00
//Required Verification for creating an server
if (config('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && ! Auth::user()->hasVerifiedEmail()) {
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 (config('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && ! Auth::user()->discordUser) {
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([
2022-05-30 09:07:10 +00:00
'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
'isPaymentSetup' => $isPaymentSetup,
2021-06-05 09:26:32 +00:00
]);
}
}