StoreController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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. $isStoreEnabled = $general_settings->store_enabled;
  13. //Required Verification for creating an server
  14. if ($user_settings->force_email_verification && !Auth::user()->hasVerifiedEmail()) {
  15. return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can purchase credits.'));
  16. }
  17. //Required Verification for creating an server
  18. if ($user_settings->force_discord_verification && !Auth::user()->discordUser) {
  19. return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
  20. }
  21. return view('store.index')->with([
  22. 'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
  23. 'isStoreEnabled' => $isStoreEnabled,
  24. 'credits_display_name' => $general_settings->credits_display_name
  25. ]);
  26. }
  27. }