StoreController.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\Configuration;
  4. use App\Models\CreditProduct;
  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. $isPaypalSetup = false;
  12. $isStripeSetup = false;
  13. if (env('PAYPAL_SECRET') && env('PAYPAL_CLIENT_ID')) $isPaypalSetup = true;
  14. if (env('APP_ENV', 'local') == 'local') {
  15. $isPaypalSetup = true;
  16. $isStripeSetup = true;
  17. }
  18. if (env('STRIPE_SECRET') && env('STRIPE_ENDPOINT_SECRET') && env('STRIPE_METHODS')) $isStripeSetup = true;
  19. //Required Verification for creating an server
  20. if (Configuration::getValueByKey('FORCE_EMAIL_VERIFICATION', false) === 'true' && !Auth::user()->hasVerifiedEmail()) {
  21. return redirect()->route('profile.index')->with('error', __("You are required to verify your email address before you can purchase credits."));
  22. }
  23. //Required Verification for creating an server
  24. if (Configuration::getValueByKey('FORCE_DISCORD_VERIFICATION', false) === 'true' && !Auth::user()->discordUser) {
  25. return redirect()->route('profile.index')->with('error', __("You are required to link your discord account before you can purchase Credits"));
  26. }
  27. return view('store.index')->with([
  28. 'products' => CreditProduct::where('disabled', '=', false)->orderBy('price', 'asc')->get(),
  29. 'isPaypalSetup' => $isPaypalSetup,
  30. 'isStripeSetup' => $isStripeSetup
  31. ]);
  32. }
  33. }