StoreController.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\CreditProduct;
  4. use App\Models\Settings;
  5. use Illuminate\Support\Facades\Auth;
  6. class StoreController extends Controller
  7. {
  8. /** Display a listing of the resource. */
  9. public function index()
  10. {
  11. $isPaymentSetup = false;
  12. if (
  13. env('APP_ENV') == 'local' ||
  14. env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID') ||
  15. env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')
  16. ) $isPaymentSetup = true;
  17. //Required Verification for creating an server
  18. if (Settings::getValueByKey('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
  19. return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits."));
  20. }
  21. //Required Verification for creating an server
  22. if (Settings::getValueByKey('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
  23. return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits"));
  24. }
  25. return view('store.index')->with([
  26. 'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
  27. 'isPaymentSetup' => $isPaymentSetup,
  28. ]);
  29. }
  30. }