StoreController.php 1.5 KB

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