2021-06-05 09:26:32 +00:00
< ? php
namespace App\Http\Controllers ;
2021-06-26 20:04:23 +00:00
use App\Models\Configuration ;
2021-06-05 09:26:32 +00:00
use App\Models\PaypalProduct ;
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. */
2021-06-06 21:26:36 +00:00
public function index ()
2021-06-05 09:26:32 +00:00
{
$isPaypalSetup = false ;
if ( env ( 'PAYPAL_SECRET' ) && env ( 'PAYPAL_CLIENT_ID' )) $isPaypalSetup = true ;
2021-06-26 20:04:23 +00:00
if ( env ( 'APP_ENV' , 'local' ) == 'local' ) $isPaypalSetup = true ;
//Required Verification for creating an server
if ( Configuration :: getValueByKey ( 'FORCE_EMAIL_VERIFICATION' , false ) === 'true' && ! Auth :: user () -> hasVerifiedEmail ()) {
2021-06-26 21:56:54 +00:00
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
if ( Configuration :: getValueByKey ( 'FORCE_DISCORD_VERIFICATION' , false ) === 'true' && ! Auth :: user () -> discordUser ) {
2021-08-02 17:25:33 +00:00
return redirect () -> route ( 'profile.index' ) -> with ( 'error' , " You are required to link your discord account before you can purchase " . CREDITS_DISPLAY_NAME . " . " );
2021-06-26 20:04:23 +00:00
}
2021-06-05 09:26:32 +00:00
return view ( 'store.index' ) -> with ([
2021-06-26 20:04:23 +00:00
'products' => PaypalProduct :: where ( 'disabled' , '=' , false ) -> orderBy ( 'price' , 'asc' ) -> get (),
2021-06-05 09:26:32 +00:00
'isPaypalSetup' => $isPaypalSetup
]);
}
}