StoreController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\ShopProduct;
  4. use App\Settings\UserSettings;
  5. use Illuminate\Support\Facades\Auth;
  6. class StoreController extends Controller
  7. {
  8. /** Display a listing of the resource. */
  9. public function index(UserSettings $user_settings)
  10. {
  11. $isPaymentSetup = false;
  12. if (
  13. env('APP_ENV') == 'local' ||
  14. config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
  15. config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
  16. ) {
  17. $isPaymentSetup = true;
  18. }
  19. //Required Verification for creating an server
  20. if ($user_settings->force_email_verification && ! 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 ($user_settings->force_discord_verification && ! 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' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
  29. 'isPaymentSetup' => $isPaymentSetup,
  30. ]);
  31. }
  32. }