StoreController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\ShopProduct;
  4. use App\Settings\GeneralSettings;
  5. use App\Settings\UserSettings;
  6. use Illuminate\Support\Facades\Auth;
  7. class StoreController extends Controller
  8. {
  9. /** Display a listing of the resource. */
  10. public function index(UserSettings $user_settings, GeneralSettings $general_settings)
  11. {
  12. $isPaymentSetup = false;
  13. if (
  14. env('APP_ENV') == 'local' ||
  15. config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
  16. config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
  17. ) {
  18. $isPaymentSetup = true;
  19. }
  20. //Required Verification for creating an server
  21. if ($user_settings->force_email_verification && ! Auth::user()->hasVerifiedEmail()) {
  22. return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can purchase credits.'));
  23. }
  24. //Required Verification for creating an server
  25. if ($user_settings->force_discord_verification && ! Auth::user()->discordUser) {
  26. return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
  27. }
  28. return view('store.index')->with([
  29. 'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
  30. 'isPaymentSetup' => true,
  31. 'credits_display_name' => $general_settings->credits_display_name
  32. ]);
  33. }
  34. }