StoreController.php 1.3 KB

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