ctrlpanel/app/Http/Controllers/StoreController.php

34 lines
1.3 KiB
PHP
Raw Normal View History

2021-06-05 09:26:32 +00:00
<?php
namespace App\Http\Controllers;
2022-05-30 09:07:10 +00:00
use App\Models\ShopProduct;
2023-02-06 21:01:20 +00:00
use App\Settings\GeneralSettings;
2023-02-04 16:40:42 +00:00
use App\Settings\UserSettings;
2021-06-26 20:04:23 +00:00
use Illuminate\Support\Facades\Auth;
2021-06-05 09:26:32 +00:00
class StoreController extends Controller
{
2021-06-06 18:17:52 +00:00
/** Display a listing of the resource. */
2023-02-06 21:01:20 +00:00
public function index(UserSettings $user_settings, GeneralSettings $general_settings)
2021-06-05 09:26:32 +00:00
{
2023-03-04 19:41:02 +00:00
$isStoreEnabled = $general_settings->store_enabled;
2021-06-26 20:04:23 +00:00
//Required Verification for creating an server
2023-03-04 19:41:02 +00:00
if ($user_settings->force_email_verification && !Auth::user()->hasVerifiedEmail()) {
return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can purchase credits.'));
2021-06-26 20:04:23 +00:00
}
//Required Verification for creating an server
2023-03-04 19:41:02 +00:00
if ($user_settings->force_discord_verification && !Auth::user()->discordUser) {
return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
2021-06-26 20:04:23 +00:00
}
2021-06-05 09:26:32 +00:00
return view('store.index')->with([
2022-05-30 09:07:10 +00:00
'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
2023-03-04 19:41:02 +00:00
'isStoreEnabled' => $isStoreEnabled,
2023-02-06 21:01:20 +00:00
'credits_display_name' => $general_settings->credits_display_name
2021-06-05 09:26:32 +00:00
]);
}
}