Merge branch 'ControlPanel-gg:development' into development
This commit is contained in:
commit
4ae54d736f
67
app/Extensions/PaymentGateways/PayPal/PayPalSettings.php
Normal file
67
app/Extensions/PaymentGateways/PayPal/PayPalSettings.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Extensions\PaymentGateways\PayPal;
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Settings;
|
||||||
|
|
||||||
|
class PayPalSettings extends Settings
|
||||||
|
{
|
||||||
|
public bool $enabled = false;
|
||||||
|
public ?string $client_id;
|
||||||
|
public ?string $client_secret;
|
||||||
|
public ?string $sandbox_client_id;
|
||||||
|
public ?string $sandbox_client_secret;
|
||||||
|
|
||||||
|
public static function group(): string
|
||||||
|
{
|
||||||
|
return 'paypal';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function encrypted(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'client_id',
|
||||||
|
'client_secret',
|
||||||
|
'sandbox_client_id',
|
||||||
|
'sandbox_client_secret'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Summary of optionInputData array
|
||||||
|
* Only used for the settings page
|
||||||
|
* @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
|
||||||
|
*/
|
||||||
|
public static function getOptionInputData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'category_icon' => 'fas fa-dollar-sign',
|
||||||
|
'client_id' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Client ID',
|
||||||
|
'description' => 'The Client ID of your PayPal App',
|
||||||
|
],
|
||||||
|
'client_secret' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Client Secret',
|
||||||
|
'description' => 'The Client Secret of your PayPal App',
|
||||||
|
],
|
||||||
|
'enabled' => [
|
||||||
|
'type' => 'boolean',
|
||||||
|
'label' => 'Enabled',
|
||||||
|
'description' => 'Enable this payment gateway',
|
||||||
|
],
|
||||||
|
'sandbox_client_id' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Sandbox Client ID',
|
||||||
|
'description' => 'The Sandbox Client ID used when app_env = local',
|
||||||
|
],
|
||||||
|
'sandbox_client_secret' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Sandbox Client Secret',
|
||||||
|
'description' => 'The Sandbox Client Secret used when app_env = local',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,8 +6,6 @@ function getConfig()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"name" => "PayPal",
|
"name" => "PayPal",
|
||||||
"description" => "PayPal payment gateway",
|
|
||||||
"RoutesIgnoreCsrf" => [],
|
"RoutesIgnoreCsrf" => [],
|
||||||
"enabled" => (config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID')) || (config('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') && env("APP_ENV") === "local"),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use App\Events\PaymentEvent;
|
use App\Events\PaymentEvent;
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
|
use App\Extensions\PaymentGateways\PayPal\PayPalSettings;
|
||||||
use App\Models\PartnerDiscount;
|
use App\Models\PartnerDiscount;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\ShopProduct;
|
use App\Models\ShopProduct;
|
||||||
|
@ -25,6 +26,8 @@ use PayPalHttp\HttpException;
|
||||||
*/
|
*/
|
||||||
function PaypalPay(Request $request)
|
function PaypalPay(Request $request)
|
||||||
{
|
{
|
||||||
|
$settings = new PayPalSettings();
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$shopProduct = ShopProduct::findOrFail($request->shopProduct);
|
$shopProduct = ShopProduct::findOrFail($request->shopProduct);
|
||||||
|
@ -111,6 +114,8 @@ function PaypalPay(Request $request)
|
||||||
*/
|
*/
|
||||||
function PaypalSuccess(Request $laravelRequest)
|
function PaypalSuccess(Request $laravelRequest)
|
||||||
{
|
{
|
||||||
|
$settings = new PayPalSettings();
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$user = User::findOrFail($user->id);
|
$user = User::findOrFail($user->id);
|
||||||
|
|
||||||
|
@ -165,6 +170,8 @@ function PaypalSuccess(Request $laravelRequest)
|
||||||
*/
|
*/
|
||||||
function getPayPalClient()
|
function getPayPalClient()
|
||||||
{
|
{
|
||||||
|
$settings = new PayPalSettings();
|
||||||
|
|
||||||
$environment = env('APP_ENV') == 'local'
|
$environment = env('APP_ENV') == 'local'
|
||||||
? new SandboxEnvironment(getPaypalClientId(), getPaypalClientSecret())
|
? new SandboxEnvironment(getPaypalClientId(), getPaypalClientSecret())
|
||||||
: new ProductionEnvironment(getPaypalClientId(), getPaypalClientSecret());
|
: new ProductionEnvironment(getPaypalClientId(), getPaypalClientSecret());
|
||||||
|
@ -175,12 +182,14 @@ function getPayPalClient()
|
||||||
*/
|
*/
|
||||||
function getPaypalClientId()
|
function getPaypalClientId()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID") : config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID");
|
$settings = new PayPalSettings();
|
||||||
|
return env('APP_ENV') == 'local' ? $settings->sandbox_client_id : $settings->client_id;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getPaypalClientSecret()
|
function getPaypalClientSecret()
|
||||||
{
|
{
|
||||||
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : config("SETTINGS::PAYMENTS:PAYPAL:SECRET");
|
$settings = new PayPalSettings();
|
||||||
|
return env('APP_ENV') == 'local' ? $settings->sandbox_client_secret : $settings->client_secret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
||||||
|
class CreatePayPalSettings extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
|
|
||||||
|
$this->migrator->addEncrypted('paypal.client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') : null);
|
||||||
|
$this->migrator->addEncrypted('paypal.client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SECRET') : null);
|
||||||
|
$this->migrator->addEncrypted('paypal.sandbox_client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : null);
|
||||||
|
$this->migrator->addEncrypted('paypal.sandbox_client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : null);
|
||||||
|
$this->migrator->add('paypal.enabled', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
DB::table('settings_old')->insert([
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID',
|
||||||
|
'value' => $this->getNewValue('client_id'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Client ID of your PayPal App'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:PAYPAL:SECRET',
|
||||||
|
'value' => $this->getNewValue('client_secret'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Client Secret of your PayPal App'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID',
|
||||||
|
'value' => $this->getNewValue('sandbox_client_id'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Sandbox Client ID of your PayPal App'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET',
|
||||||
|
'value' => $this->getNewValue('sandbox_client_secret'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Sandbox Client Secret of your PayPal App'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$this->migrator->delete('paypal.client_id');
|
||||||
|
$this->migrator->delete('paypal.client_secret');
|
||||||
|
$this->migrator->delete('paypal.enabled');
|
||||||
|
$this->migrator->delete('paypal.sandbox_client_id');
|
||||||
|
$this->migrator->delete('paypal.sandbox_client_secret');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNewValue(string $name)
|
||||||
|
{
|
||||||
|
$new_value = DB::table('settings')->where([['group', '=', 'paypal'], ['name', '=', $name]])->get(['payload'])->first();
|
||||||
|
|
||||||
|
// Some keys returns '""' as a value.
|
||||||
|
if ($new_value->payload === '""') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove the quotes from the string
|
||||||
|
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
||||||
|
return substr($new_value->payload, 1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_value->payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOldValue(string $key)
|
||||||
|
{
|
||||||
|
// Always get the first value of the key.
|
||||||
|
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||||
|
|
||||||
|
// Handle the old values to return without it being a string in all cases.
|
||||||
|
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||||
|
if (is_null($old_value->value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some values have the type string, but their values are boolean.
|
||||||
|
if ($old_value->value === "false" || $old_value->value === "true") {
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $old_value->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($old_value->type === "boolean") {
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||||
|
}
|
||||||
|
}
|
63
app/Extensions/PaymentGateways/Stripe/StripeSettings.php
Normal file
63
app/Extensions/PaymentGateways/Stripe/StripeSettings.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Extensions\PaymentGateways\Stripe;
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Settings;
|
||||||
|
|
||||||
|
class StripeSettings extends Settings
|
||||||
|
{
|
||||||
|
|
||||||
|
public bool $enabled = false;
|
||||||
|
public ?string $secret_key;
|
||||||
|
public ?string $endpoint_secret;
|
||||||
|
public ?string $test_secret_key;
|
||||||
|
public ?string $test_endpoint_secret;
|
||||||
|
|
||||||
|
|
||||||
|
public static function group(): string
|
||||||
|
{
|
||||||
|
return 'stripe';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function encrypted(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"secret_key",
|
||||||
|
"endpoint_secret",
|
||||||
|
"test_secret_key",
|
||||||
|
"test_endpoint_secret"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getOptionInputData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'category_icon' => 'fas fa-dollar-sign',
|
||||||
|
'secret_key' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Secret Key',
|
||||||
|
'description' => 'The Secret Key of your Stripe App',
|
||||||
|
],
|
||||||
|
'endpoint_secret' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Endpoint Secret',
|
||||||
|
'description' => 'The Endpoint Secret of your Stripe App',
|
||||||
|
],
|
||||||
|
'test_secret_key' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Test Secret Key',
|
||||||
|
'description' => 'The Test Secret Key used when app_env = local',
|
||||||
|
],
|
||||||
|
'test_endpoint_secret' => [
|
||||||
|
'type' => 'string',
|
||||||
|
'label' => 'Test Endpoint Secret',
|
||||||
|
'description' => 'The Test Endpoint Secret used when app_env = local',
|
||||||
|
],
|
||||||
|
'enabled' => [
|
||||||
|
'type' => 'boolean',
|
||||||
|
'label' => 'Enabled',
|
||||||
|
'description' => 'Enable this payment gateway',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,10 +6,8 @@ function getConfig()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"name" => "Stripe",
|
"name" => "Stripe",
|
||||||
"description" => "Stripe payment gateway",
|
|
||||||
"RoutesIgnoreCsrf" => [
|
"RoutesIgnoreCsrf" => [
|
||||||
"payment/StripeWebhooks",
|
"payment/StripeWebhooks",
|
||||||
],
|
],
|
||||||
"enabled" => config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') || config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') && env("APP_ENV") === "local",
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use App\Events\PaymentEvent;
|
use App\Events\PaymentEvent;
|
||||||
use App\Events\UserUpdateCreditsEvent;
|
use App\Events\UserUpdateCreditsEvent;
|
||||||
|
use App\Extensions\PaymentGateways\Stripe\StripeSettings;
|
||||||
use App\Models\PartnerDiscount;
|
use App\Models\PartnerDiscount;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\ShopProduct;
|
use App\Models\ShopProduct;
|
||||||
|
@ -79,7 +80,6 @@ function StripePay(Request $request)
|
||||||
],
|
],
|
||||||
|
|
||||||
'mode' => 'payment',
|
'mode' => 'payment',
|
||||||
'payment_method_types' => str_getcsv(config('SETTINGS::PAYMENTS:STRIPE:METHODS')),
|
|
||||||
'success_url' => route('payment.StripeSuccess', ['payment' => $payment->id]) . '&session_id={CHECKOUT_SESSION_ID}',
|
'success_url' => route('payment.StripeSuccess', ['payment' => $payment->id]) . '&session_id={CHECKOUT_SESSION_ID}',
|
||||||
'cancel_url' => route('payment.Cancel'),
|
'cancel_url' => route('payment.Cancel'),
|
||||||
'payment_intent_data' => [
|
'payment_intent_data' => [
|
||||||
|
@ -244,9 +244,11 @@ function getStripeClient()
|
||||||
*/
|
*/
|
||||||
function getStripeSecret()
|
function getStripeSecret()
|
||||||
{
|
{
|
||||||
|
$settings = new StripeSettings();
|
||||||
|
|
||||||
return env('APP_ENV') == 'local'
|
return env('APP_ENV') == 'local'
|
||||||
? config('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET')
|
? $settings->test_secret_key
|
||||||
: config('SETTINGS::PAYMENTS:STRIPE:SECRET');
|
: $settings->secret_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,9 +256,10 @@ function getStripeSecret()
|
||||||
*/
|
*/
|
||||||
function getStripeEndpointSecret()
|
function getStripeEndpointSecret()
|
||||||
{
|
{
|
||||||
|
$settings = new StripeSettings();
|
||||||
return env('APP_ENV') == 'local'
|
return env('APP_ENV') == 'local'
|
||||||
? config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET')
|
? $settings->test_endpoint_secret
|
||||||
: config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET');
|
: $settings->endpoint_secret;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param $amount
|
* @param $amount
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class CreateStripeSettings extends SettingsMigration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
|
$this->migrator->addEncrypted('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null);
|
||||||
|
$this->migrator->addEncrypted('stripe.endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') : null);
|
||||||
|
$this->migrator->addEncrypted('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null);
|
||||||
|
$this->migrator->addEncrypted('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null);
|
||||||
|
$this->migrator->add('stripe.enabled', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
DB::table('settings_old')->insert([
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:STRIPE:SECRET',
|
||||||
|
'value' => $this->getNewValue('secret_key'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Secret Key of your Stripe App'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET',
|
||||||
|
'value' => $this->getNewValue('endpoint_secret'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Endpoint Secret of your Stripe App'
|
||||||
|
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:STRIPE:TEST_SECRET',
|
||||||
|
'value' => $this->getNewValue('test_secret_key'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Test Secret Key of your Stripe App'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'key' => 'SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET',
|
||||||
|
'value' => $this->getNewValue('test_endpoint_secret'),
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'The Test Endpoint Secret of your Stripe App'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->migrator->delete('stripe.secret_key');
|
||||||
|
$this->migrator->delete('stripe.endpoint_secret');
|
||||||
|
$this->migrator->delete('stripe.enabled');
|
||||||
|
$this->migrator->delete('stripe.test_secret_key');
|
||||||
|
$this->migrator->delete('stripe.test_endpoint_secret');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNewValue(string $name)
|
||||||
|
{
|
||||||
|
$new_value = DB::table('settings')->where([['group', '=', 'stripe'], ['name', '=', $name]])->get(['payload'])->first();
|
||||||
|
|
||||||
|
// Some keys returns '""' as a value.
|
||||||
|
if ($new_value->payload === '""') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove the quotes from the string
|
||||||
|
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
|
||||||
|
return substr($new_value->payload, 1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new_value->payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOldValue(string $key)
|
||||||
|
{
|
||||||
|
// Always get the first value of the key.
|
||||||
|
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
|
||||||
|
|
||||||
|
// Handle the old values to return without it being a string in all cases.
|
||||||
|
if ($old_value->type === "string" || $old_value->type === "text") {
|
||||||
|
if (is_null($old_value->value)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some values have the type string, but their values are boolean.
|
||||||
|
if ($old_value->value === "false" || $old_value->value === "true") {
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $old_value->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($old_value->type === "boolean") {
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filter_var($old_value->value, FILTER_VALIDATE_INT);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Summary of ExtensionHelper
|
||||||
|
*/
|
||||||
class ExtensionHelper
|
class ExtensionHelper
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +63,7 @@ class ExtensionHelper
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all extensions
|
* Get all extensions
|
||||||
* @return array
|
* @return array of all extension paths look like: app/Extensions/ExtensionNamespace/ExtensionName
|
||||||
*/
|
*/
|
||||||
public static function getAllExtensions()
|
public static function getAllExtensions()
|
||||||
{
|
{
|
||||||
|
@ -79,4 +82,75 @@ class ExtensionHelper
|
||||||
|
|
||||||
return $extensions;
|
return $extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Summary of getAllExtensionMigrations
|
||||||
|
* @return array of all migration paths look like: app/Extensions/ExtensionNamespace/ExtensionName/migrations/
|
||||||
|
*/
|
||||||
|
public static function getAllExtensionMigrations()
|
||||||
|
{
|
||||||
|
$extensions = ExtensionHelper::getAllExtensions();
|
||||||
|
|
||||||
|
// get all migration directories of the extensions and return them as array
|
||||||
|
$migrations = [];
|
||||||
|
foreach ($extensions as $extension) {
|
||||||
|
$migrationDir = $extension . '/migrations';
|
||||||
|
if (file_exists($migrationDir)) {
|
||||||
|
$migrations[] = $migrationDir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $migrations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Summary of getAllExtensionSettings
|
||||||
|
* @return array of all setting classes look like: App\Extensions\PaymentGateways\PayPal\PayPalSettings
|
||||||
|
*/
|
||||||
|
public static function getAllExtensionSettingsClasses()
|
||||||
|
{
|
||||||
|
$extensions = ExtensionHelper::getAllExtensions();
|
||||||
|
|
||||||
|
$settings = [];
|
||||||
|
foreach ($extensions as $extension) {
|
||||||
|
|
||||||
|
$extensionName = basename($extension);
|
||||||
|
$settingFile = $extension . '/' . $extensionName . 'Settings.php';
|
||||||
|
if (file_exists($settingFile)) {
|
||||||
|
// remove the base path from the setting file path to get the namespace
|
||||||
|
|
||||||
|
$settingFile = str_replace(app_path() . '/', '', $settingFile);
|
||||||
|
$settingFile = str_replace('.php', '', $settingFile);
|
||||||
|
$settingFile = str_replace('/', '\\', $settingFile);
|
||||||
|
$settingFile = 'App\\' . $settingFile;
|
||||||
|
$settings[] = $settingFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getExtensionSettings(string $extensionName)
|
||||||
|
{
|
||||||
|
$extensions = ExtensionHelper::getAllExtensions();
|
||||||
|
|
||||||
|
// find the setting file of the extension and return an instance of it
|
||||||
|
foreach ($extensions as $extension) {
|
||||||
|
if (!(basename($extension) == $extensionName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extensionName = basename($extension);
|
||||||
|
$settingFile = $extension . '/' . $extensionName . 'Settings.php';
|
||||||
|
if (file_exists($settingFile)) {
|
||||||
|
// remove the base path from the setting file path to get the namespace
|
||||||
|
|
||||||
|
$settingFile = str_replace(app_path() . '/', '', $settingFile);
|
||||||
|
$settingFile = str_replace('.php', '', $settingFile);
|
||||||
|
$settingFile = str_replace('/', '\\', $settingFile);
|
||||||
|
$settingFile = 'App\\' . $settingFile;
|
||||||
|
return new $settingFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,10 @@ class PaymentController extends Controller
|
||||||
// build a paymentgateways array that contains the routes for the payment gateways and the image path for the payment gateway which lays in public/images/Extensions/PaymentGateways with the extensionname in lowercase
|
// build a paymentgateways array that contains the routes for the payment gateways and the image path for the payment gateway which lays in public/images/Extensions/PaymentGateways with the extensionname in lowercase
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
$extensionName = basename($extension);
|
$extensionName = basename($extension);
|
||||||
if (!ExtensionHelper::getExtensionConfig($extensionName, 'enabled')) continue; // skip if not enabled
|
|
||||||
|
$extensionSettings = ExtensionHelper::getExtensionSettings($extensionName);
|
||||||
|
if ($extensionSettings->enabled == false) continue;
|
||||||
|
|
||||||
|
|
||||||
$payment = new \stdClass();
|
$payment = new \stdClass();
|
||||||
$payment->name = ExtensionHelper::getExtensionConfig($extensionName, 'name');
|
$payment->name = ExtensionHelper::getExtensionConfig($extensionName, 'name');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Helpers\ExtensionHelper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
@ -25,13 +26,26 @@ class SettingsController extends Controller
|
||||||
// get all other settings in app/Settings directory
|
// get all other settings in app/Settings directory
|
||||||
// group items by file name like $categories
|
// group items by file name like $categories
|
||||||
$settings = collect();
|
$settings = collect();
|
||||||
foreach (scandir(app_path('Settings')) as $file) {
|
$settings_classes = [];
|
||||||
if (in_array($file, ['.', '..'])) {
|
|
||||||
continue;
|
// get all app settings
|
||||||
|
$app_settings = scandir(app_path('Settings'));
|
||||||
|
$app_settings = array_diff($app_settings, ['.', '..']);
|
||||||
|
// append App\Settings to class name
|
||||||
|
foreach ($app_settings as $app_setting) {
|
||||||
|
$settings_classes[] = 'App\\Settings\\' . str_replace('.php', '', $app_setting);
|
||||||
}
|
}
|
||||||
$className = 'App\\Settings\\' . str_replace('.php', '', $file);
|
// get all extension settings
|
||||||
|
$settings_files = array_merge($settings_classes, ExtensionHelper::getAllExtensionSettingsClasses());
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($settings_files as $file) {
|
||||||
|
|
||||||
|
$className = $file;
|
||||||
|
// instantiate the class and call toArray method to get all options
|
||||||
$options = (new $className())->toArray();
|
$options = (new $className())->toArray();
|
||||||
|
|
||||||
|
// call getOptionInputData method to get all options
|
||||||
if (method_exists($className, 'getOptionInputData')) {
|
if (method_exists($className, 'getOptionInputData')) {
|
||||||
$optionInputData = $className::getOptionInputData();
|
$optionInputData = $className::getOptionInputData();
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,8 +68,9 @@ class SettingsController extends Controller
|
||||||
if (isset($optionInputData['category_icon'])) {
|
if (isset($optionInputData['category_icon'])) {
|
||||||
$optionsData['category_icon'] = $optionInputData['category_icon'];
|
$optionsData['category_icon'] = $optionInputData['category_icon'];
|
||||||
}
|
}
|
||||||
|
$optionsData['settings_class'] = $className;
|
||||||
|
|
||||||
$settings[str_replace('Settings.php', '', $file)] = $optionsData;
|
$settings[str_replace('Settings', '', class_basename($className))] = $optionsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
$settings->sort();
|
$settings->sort();
|
||||||
|
@ -77,10 +92,10 @@ class SettingsController extends Controller
|
||||||
public function update(Request $request)
|
public function update(Request $request)
|
||||||
{
|
{
|
||||||
$category = request()->get('category');
|
$category = request()->get('category');
|
||||||
|
$settings_class = request()->get('settings_class');
|
||||||
|
|
||||||
$className = 'App\\Settings\\' . $category . 'Settings';
|
if (method_exists($settings_class, 'getValidations')) {
|
||||||
if (method_exists($className, 'getValidations')) {
|
$validations = $settings_class::getValidations();
|
||||||
$validations = $className::getValidations();
|
|
||||||
} else {
|
} else {
|
||||||
$validations = [];
|
$validations = [];
|
||||||
}
|
}
|
||||||
|
@ -91,7 +106,7 @@ class SettingsController extends Controller
|
||||||
return Redirect::to('admin/settings' . '#' . $category)->withErrors($validator)->withInput();
|
return Redirect::to('admin/settings' . '#' . $category)->withErrors($validator)->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
$settingsClass = new $className();
|
$settingsClass = new $settings_class();
|
||||||
|
|
||||||
foreach ($settingsClass->toArray() as $key => $value) {
|
foreach ($settingsClass->toArray() as $key => $value) {
|
||||||
switch (gettype($value)) {
|
switch (gettype($value)) {
|
||||||
|
|
|
@ -22,20 +22,13 @@ class ShopProductController extends Controller
|
||||||
*
|
*
|
||||||
* @return Application|Factory|View|Response
|
* @return Application|Factory|View|Response
|
||||||
*/
|
*/
|
||||||
public function index(LocaleSettings $locale_settings)
|
public function index(LocaleSettings $locale_settings, GeneralSettings $general_settings)
|
||||||
{
|
{
|
||||||
$isPaymentSetup = false;
|
$isStoreEnabled = $general_settings->store_enabled;
|
||||||
|
|
||||||
if (
|
|
||||||
env('APP_ENV') == 'local' ||
|
|
||||||
config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
|
|
||||||
config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
|
|
||||||
) {
|
|
||||||
$isPaymentSetup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('admin.store.index', [
|
return view('admin.store.index', [
|
||||||
'isPaymentSetup' => $isPaymentSetup,
|
'isStoreEnabled' => $isStoreEnabled,
|
||||||
'locale_datatables' => $locale_settings->datatables
|
'locale_datatables' => $locale_settings->datatables
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,29 +12,21 @@ class StoreController extends Controller
|
||||||
/** Display a listing of the resource. */
|
/** Display a listing of the resource. */
|
||||||
public function index(UserSettings $user_settings, GeneralSettings $general_settings)
|
public function index(UserSettings $user_settings, GeneralSettings $general_settings)
|
||||||
{
|
{
|
||||||
$isPaymentSetup = false;
|
$isStoreEnabled = $general_settings->store_enabled;
|
||||||
|
|
||||||
if (
|
|
||||||
env('APP_ENV') == 'local' ||
|
|
||||||
config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') ||
|
|
||||||
config('SETTINGS::PAYMENTS:STRIPE:SECRET') && config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') && config('SETTINGS::PAYMENTS:STRIPE:METHODS')
|
|
||||||
) {
|
|
||||||
$isPaymentSetup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
if ($user_settings->force_email_verification && ! Auth::user()->hasVerifiedEmail()) {
|
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.'));
|
return redirect()->route('profile.index')->with('error', __('You are required to verify your email address before you can purchase credits.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Required Verification for creating an server
|
//Required Verification for creating an server
|
||||||
if ($user_settings->force_discord_verification && ! Auth::user()->discordUser) {
|
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'));
|
return redirect()->route('profile.index')->with('error', __('You are required to link your discord account before you can purchase Credits'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('store.index')->with([
|
return view('store.index')->with([
|
||||||
'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
|
'products' => ShopProduct::where('disabled', '=', false)->orderBy('type', 'asc')->orderBy('price', 'asc')->get(),
|
||||||
'isPaymentSetup' => true,
|
'isStoreEnabled' => $isStoreEnabled,
|
||||||
'credits_display_name' => $general_settings->credits_display_name
|
'credits_display_name' => $general_settings->credits_display_name
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Extensions\PaymentGateways\PayPal\PayPalSettings;
|
||||||
use App\Models\UsefulLink;
|
use App\Models\UsefulLink;
|
||||||
use App\Settings\MailSettings;
|
use App\Settings\MailSettings;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -10,7 +11,7 @@ use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Qirolab\Theme\Theme;
|
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
@ -64,91 +65,5 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
$settings = $this->app->make(MailSettings::class);
|
$settings = $this->app->make(MailSettings::class);
|
||||||
$settings->setConfig();
|
$settings->setConfig();
|
||||||
|
|
||||||
//only run if the installer has been executed
|
|
||||||
// try {
|
|
||||||
// $settings = Settings::all();
|
|
||||||
// // Set all configs from database
|
|
||||||
// foreach ($settings as $setting) {
|
|
||||||
// config([$setting->key => $setting->value]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(!file_exists(base_path('themes') . "/" . config("SETTINGS::SYSTEM:THEME"))){
|
|
||||||
// config(['SETTINGS::SYSTEM:THEME' => "default"]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(config('SETTINGS::SYSTEM:THEME') !== config('theme.active')){
|
|
||||||
// Theme::set(config("SETTINGS::SYSTEM:THEME"), "default");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Set Mail Config
|
|
||||||
// //only update config if mail settings have changed in DB
|
|
||||||
// if (
|
|
||||||
// config('mail.default') != config('SETTINGS:MAIL:MAILER') ||
|
|
||||||
// config('mail.mailers.smtp.host') != config('SETTINGS:MAIL:HOST') ||
|
|
||||||
// config('mail.mailers.smtp.port') != config('SETTINGS:MAIL:PORT') ||
|
|
||||||
// config('mail.mailers.smtp.username') != config('SETTINGS:MAIL:USERNAME') ||
|
|
||||||
// config('mail.mailers.smtp.password') != config('SETTINGS:MAIL:PASSWORD') ||
|
|
||||||
// config('mail.mailers.smtp.encryption') != config('SETTINGS:MAIL:ENCRYPTION') ||
|
|
||||||
// config('mail.from.address') != config('SETTINGS:MAIL:FROM_ADDRESS') ||
|
|
||||||
// config('mail.from.name') != config('SETTINGS:MAIL:FROM_NAME')
|
|
||||||
// ) {
|
|
||||||
// config(['mail.default' => config('SETTINGS::MAIL:MAILER')]);
|
|
||||||
// config(['mail.mailers.smtp' => [
|
|
||||||
// 'transport' => 'smtp',
|
|
||||||
// 'host' => config('SETTINGS::MAIL:HOST'),
|
|
||||||
// 'port' => config('SETTINGS::MAIL:PORT'),
|
|
||||||
// 'encryption' => config('SETTINGS::MAIL:ENCRYPTION'),
|
|
||||||
// 'username' => config('SETTINGS::MAIL:USERNAME'),
|
|
||||||
// 'password' => config('SETTINGS::MAIL:PASSWORD'),
|
|
||||||
// 'timeout' => null,
|
|
||||||
// 'auth_mode' => null,
|
|
||||||
// ]]);
|
|
||||||
// config(['mail.from' => ['address' => config('SETTINGS::MAIL:FROM_ADDRESS'), 'name' => config('SETTINGS::MAIL:FROM_NAME')]]);
|
|
||||||
|
|
||||||
// Artisan::call('queue:restart');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Set Recaptcha API Config
|
|
||||||
// // Load recaptcha package if recaptcha is enabled
|
|
||||||
// if (config('SETTINGS::RECAPTCHA:ENABLED') == 'true') {
|
|
||||||
// $this->app->register(\Biscolab\ReCaptcha\ReCaptchaServiceProvider::class);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //only update config if recaptcha settings have changed in DB
|
|
||||||
// if (
|
|
||||||
// config('recaptcha.api_site_key') != config('SETTINGS::RECAPTCHA:SITE_KEY') ||
|
|
||||||
// config('recaptcha.api_secret_key') != config('SETTINGS::RECAPTCHA:SECRET_KEY')
|
|
||||||
// ) {
|
|
||||||
// config(['recaptcha.api_site_key' => config('SETTINGS::RECAPTCHA:SITE_KEY')]);
|
|
||||||
// config(['recaptcha.api_secret_key' => config('SETTINGS::RECAPTCHA:SECRET_KEY')]);
|
|
||||||
|
|
||||||
// Artisan::call('config:clear');
|
|
||||||
// Artisan::call('cache:clear');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// try {
|
|
||||||
// $stringfromfile = file(base_path().'/.git/HEAD');
|
|
||||||
|
|
||||||
// $firstLine = $stringfromfile[0]; //get the string from the array
|
|
||||||
|
|
||||||
// $explodedstring = explode('/', $firstLine, 3); //seperate out by the "/" in the string
|
|
||||||
|
|
||||||
// $branchname = $explodedstring[2]; //get the one that is always the branch name
|
|
||||||
// } catch (Exception $e) {
|
|
||||||
// $branchname = 'unknown';
|
|
||||||
// Log::notice($e);
|
|
||||||
// }
|
|
||||||
// config(['BRANCHNAME' => $branchname]);
|
|
||||||
|
|
||||||
// // Set Discord-API Config
|
|
||||||
// config(['services.discord.client_id' => config('SETTINGS::DISCORD:CLIENT_ID')]);
|
|
||||||
// config(['services.discord.client_secret' => config('SETTINGS::DISCORD:CLIENT_SECRET')]);
|
|
||||||
// } catch (Exception $e) {
|
|
||||||
// error_log('Settings Error: Could not load settings from database. The Installation probably is not done yet.');
|
|
||||||
// error_log($e);
|
|
||||||
// Log::error('Settings Error: Could not load settings from database. The Installation probably is not done yet.');
|
|
||||||
// Log::error($e);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use Spatie\LaravelSettings\Settings;
|
||||||
|
|
||||||
class GeneralSettings extends Settings
|
class GeneralSettings extends Settings
|
||||||
{
|
{
|
||||||
|
public bool $store_enabled = true;
|
||||||
public string $credits_display_name;
|
public string $credits_display_name;
|
||||||
public bool $recaptcha_enabled;
|
public bool $recaptcha_enabled;
|
||||||
public string $recaptcha_site_key;
|
public string $recaptcha_site_key;
|
||||||
|
@ -31,27 +32,6 @@ class GeneralSettings extends Settings
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Summary of validations array
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function getValidations()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'credits_display_name' => 'required|string',
|
|
||||||
'initial_user_credits' => 'required|numeric',
|
|
||||||
'initial_server_limit' => 'required|numeric',
|
|
||||||
'recaptcha_enabled' => 'nullable|string',
|
|
||||||
'recaptcha_site_key' => 'nullable|string',
|
|
||||||
'recaptcha_secret_key' => 'nullable|string',
|
|
||||||
'phpmyadmin_url' => 'nullable|string',
|
|
||||||
'alert_enabled' => 'nullable|string',
|
|
||||||
'alert_type' => 'nullable|string',
|
|
||||||
'alert_message' => 'nullable|string',
|
|
||||||
'theme' => 'required|string'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of optionTypes
|
* Summary of optionTypes
|
||||||
* Only used for the settings page
|
* Only used for the settings page
|
||||||
|
@ -61,6 +41,11 @@ class GeneralSettings extends Settings
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'category_icon' => "fas fa-cog",
|
'category_icon' => "fas fa-cog",
|
||||||
|
'store_enabled' => [
|
||||||
|
'type' => 'boolean',
|
||||||
|
'label' => 'Enable Store',
|
||||||
|
'description' => 'Enable the store for users to purchase credits.'
|
||||||
|
],
|
||||||
'credits_display_name' => [
|
'credits_display_name' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Credits Display Name',
|
'label' => 'Credits Display Name',
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Helpers\ExtensionHelper;
|
||||||
use App\Settings\GeneralSettings;
|
use App\Settings\GeneralSettings;
|
||||||
use App\Settings\DiscordSettings;
|
use App\Settings\DiscordSettings;
|
||||||
use App\Settings\InvoiceSettings;
|
use App\Settings\InvoiceSettings;
|
||||||
|
@ -29,7 +30,7 @@ return [
|
||||||
ServerSettings::class,
|
ServerSettings::class,
|
||||||
UserSettings::class,
|
UserSettings::class,
|
||||||
WebsiteSettings::class,
|
WebsiteSettings::class,
|
||||||
TicketSettings::class
|
TicketSettings::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -44,6 +45,8 @@ return [
|
||||||
*/
|
*/
|
||||||
'migrations_paths' => [
|
'migrations_paths' => [
|
||||||
database_path('settings'),
|
database_path('settings'),
|
||||||
|
...ExtensionHelper::getAllExtensionMigrations()
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -88,7 +91,7 @@ return [
|
||||||
'global_casts' => [
|
'global_casts' => [
|
||||||
DateTimeInterface::class => Spatie\LaravelSettings\SettingsCasts\DateTimeInterfaceCast::class,
|
DateTimeInterface::class => Spatie\LaravelSettings\SettingsCasts\DateTimeInterfaceCast::class,
|
||||||
DateTimeZone::class => Spatie\LaravelSettings\SettingsCasts\DateTimeZoneCast::class,
|
DateTimeZone::class => Spatie\LaravelSettings\SettingsCasts\DateTimeZoneCast::class,
|
||||||
// Spatie\DataTransferObject\DataTransferObject::class => Spatie\LaravelSettings\SettingsCasts\DtoCast::class,
|
// Spatie\DataTransferObject\DataTransferObject::class => Spatie\LaravelSettings\SettingsCasts\DtoCast::class,
|
||||||
Spatie\LaravelData\Data::class => Spatie\LaravelSettings\SettingsCasts\DataCast::class,
|
Spatie\LaravelData\Data::class => Spatie\LaravelSettings\SettingsCasts\DataCast::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class CreateGeneralSettings extends SettingsMigration
|
||||||
$table_exists = DB::table('settings_old')->exists();
|
$table_exists = DB::table('settings_old')->exists();
|
||||||
|
|
||||||
// Get the user-set configuration values from the old table.
|
// Get the user-set configuration values from the old table.
|
||||||
|
$this->migrator->add('general.store_enabled', true);
|
||||||
$this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits');
|
$this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits');
|
||||||
$this->migrator->addEncrypted('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
$this->migrator->addEncrypted('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
|
||||||
$this->migrator->addEncrypted('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
$this->migrator->addEncrypted('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
|
||||||
|
@ -88,6 +89,7 @@ class CreateGeneralSettings extends SettingsMigration
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->migrator->delete('general.store_enabled');
|
||||||
$this->migrator->delete('general.credits_display_name');
|
$this->migrator->delete('general.credits_display_name');
|
||||||
$this->migrator->delete('general.recaptcha_site_key');
|
$this->migrator->delete('general.recaptcha_site_key');
|
||||||
$this->migrator->delete('general.recaptcha_secret_key');
|
$this->migrator->delete('general.recaptcha_secret_key');
|
||||||
|
|
|
@ -71,10 +71,12 @@
|
||||||
<form action="{{ route('admin.settings.update') }}" method="POST">
|
<form action="{{ route('admin.settings.update') }}" method="POST">
|
||||||
@csrf
|
@csrf
|
||||||
@method('POST')
|
@method('POST')
|
||||||
|
<input type="hidden" name="settings_class"
|
||||||
|
value="{{ $options['settings_class'] }}">
|
||||||
<input type="hidden" name="category" value="{{ $category }}">
|
<input type="hidden" name="category" value="{{ $category }}">
|
||||||
|
|
||||||
@foreach ($options as $key => $value)
|
@foreach ($options as $key => $value)
|
||||||
@if ($key == 'category_icon')
|
@if ($key == 'category_icon' || $key == 'settings_class')
|
||||||
@continue
|
@continue
|
||||||
@endif
|
@endif
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -168,9 +168,6 @@
|
||||||
<!-- /.card-body -->
|
<!-- /.card-body -->
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<!-- /.card -->
|
|
||||||
</div>
|
|
||||||
<!-- /.col -->
|
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="card card-default">
|
<div class="card card-default">
|
||||||
|
@ -297,10 +294,6 @@
|
||||||
@endif
|
@endif
|
||||||
<!-- /.card -->
|
<!-- /.card -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<!-- END CUSTOM CONTENT -->
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<!-- END CONTENT -->
|
<!-- END CONTENT -->
|
||||||
|
|
|
@ -3,13 +3,16 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@php($website_settings = app(App\Settings\WebsiteSettings::class))
|
@php($website_settings = app(App\Settings\WebsiteSettings::class))
|
||||||
|
@php($general_settings = app(App\Settings\GeneralSettings::class))
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- CSRF Token -->
|
<!-- CSRF Token -->
|
||||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||||
<meta content="{{ $website_settings->seo_title }}" property="og:title">
|
<meta content="{{ $website_settings->seo_title }}" property="og:title">
|
||||||
<meta content="{{ $website_settings->seo_description }}" property="og:description">
|
<meta content="{{ $website_settings->seo_description }}" property="og:description">
|
||||||
<meta content='{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('logo.png') ? asset('storage/logo.png') : asset('images/controlpanel_logo.png') }}' property="og:image">
|
<meta
|
||||||
|
content='{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('logo.png') ? asset('storage/logo.png') : asset('images/controlpanel_logo.png') }}'
|
||||||
|
property="og:image">
|
||||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||||
<link rel="icon"
|
<link rel="icon"
|
||||||
href="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('favicon.ico') ? asset('storage/favicon.ico') : asset('favicon.ico') }}"
|
href="{{ \Illuminate\Support\Facades\Storage::disk('public')->exists('favicon.ico') ? asset('storage/favicon.ico') : asset('favicon.ico') }}"
|
||||||
|
@ -87,10 +90,10 @@
|
||||||
</li>
|
</li>
|
||||||
<!-- End Language Selection -->
|
<!-- End Language Selection -->
|
||||||
@endif
|
@endif
|
||||||
@foreach($useful_links as $link)
|
@foreach ($useful_links as $link)
|
||||||
<li class="nav-item d-none d-sm-inline-block">
|
<li class="nav-item d-none d-sm-inline-block">
|
||||||
<a href="{{ $link->link }}" class="nav-link" target="__blank"><i
|
<a href="{{ $link->link }}" class="nav-link" target="__blank"><i
|
||||||
class="{{$link->icon}}"></i> {{ $link->title }}</a>
|
class="{{ $link->icon }}"></i> {{ $link->title }}</a>
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -232,11 +235,7 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
@if (env('APP_ENV') == 'local' ||
|
@if (env('APP_ENV') == 'local' || $general_settings->store_enabled)
|
||||||
(config('SETTINGS::PAYMENTS:PAYPAL:SECRET') && config('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID')) ||
|
|
||||||
(config('SETTINGS::PAYMENTS:STRIPE:SECRET') &&
|
|
||||||
config('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') &&
|
|
||||||
config('SETTINGS::PAYMENTS:STRIPE:METHODS')))
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="{{ route('store.index') }}"
|
<a href="{{ route('store.index') }}"
|
||||||
class="nav-link @if (Request::routeIs('store.*') || Request::routeIs('checkout')) active @endif">
|
class="nav-link @if (Request::routeIs('store.*') || Request::routeIs('checkout')) active @endif">
|
||||||
|
@ -458,7 +457,8 @@
|
||||||
<a target="_blank" href="{{ route('privacy') }}"><strong>{{ __('Privacy') }}</strong></a>
|
<a target="_blank" href="{{ route('privacy') }}"><strong>{{ __('Privacy') }}</strong></a>
|
||||||
@endif
|
@endif
|
||||||
@if ($website_settings->show_tos)
|
@if ($website_settings->show_tos)
|
||||||
| <a target="_blank" href="{{ route('tos') }}"><strong>{{ __('Terms of Service') }}</strong></a>
|
| <a target="_blank"
|
||||||
|
href="{{ route('tos') }}"><strong>{{ __('Terms of Service') }}</strong></a>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a class=""
|
<li class="breadcrumb-item"><a class="" href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
||||||
href="{{ route('home') }}">{{ __('Dashboard') }}</a></li>
|
|
||||||
<li class="breadcrumb-item"><a class="text-muted"
|
<li class="breadcrumb-item"><a class="text-muted"
|
||||||
href="{{ route('store.index') }}">{{ __('Store') }}</a></li>
|
href="{{ route('store.index') }}">{{ __('Store') }}</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
|
@ -31,8 +30,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($isPaymentSetup && $products->count() > 0)
|
@if ($isStoreEnabled && $products->count() > 0)
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h5 class="card-title"><i class="fa fa-coins mr-2"></i>{{ $credits_display_name }}</h5>
|
<h5 class="card-title"><i class="fa fa-coins mr-2"></i>{{ $credits_display_name }}</h5>
|
||||||
|
@ -51,15 +49,17 @@
|
||||||
@foreach ($products as $product)
|
@foreach ($products as $product)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $product->formatToCurrency($product->price) }}</td>
|
<td>{{ $product->formatToCurrency($product->price) }}</td>
|
||||||
<td>{{ strtolower($product->type) == 'credits' ? $credits_display_name : $product->type }}</td>
|
<td>{{ strtolower($product->type) == 'credits' ? $credits_display_name : $product->type }}
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(strtolower($product->type) == 'credits')
|
@if (strtolower($product->type) == 'credits')
|
||||||
<i class="fa fa-coins mr-2"></i>
|
<i class="fa fa-coins mr-2"></i>
|
||||||
@elseif (strtolower($product->type) == 'server slots')
|
@elseif (strtolower($product->type) == 'server slots')
|
||||||
<i class="fa fa-server mr-2"></i>
|
<i class="fa fa-server mr-2"></i>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{{ $product->display }}</td>
|
{{ $product->display }}
|
||||||
|
</td>
|
||||||
<td><a href="{{ route('checkout', $product->id) }}"
|
<td><a href="{{ route('checkout', $product->id) }}"
|
||||||
class="btn btn-info">{{ __('Purchase') }}</a>
|
class="btn btn-info">{{ __('Purchase') }}</a>
|
||||||
</td>
|
</td>
|
||||||
|
@ -69,14 +69,17 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@else
|
@else
|
||||||
<div class="alert alert-danger alert-dismissible">
|
<div class="alert alert-danger alert-dismissible">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
<h4><i class="icon fa fa-ban"></i> @if ($products->count() == 0) {{ __('There are no store products!') }} @else {{ __('The store is not correctly configured!') }} @endif
|
<h4><i class="icon fa fa-ban"></i>
|
||||||
|
@if ($products->count() == 0)
|
||||||
|
{{ __('There are no store products!') }}
|
||||||
|
@else
|
||||||
|
{{ __('The store is not correctly configured!') }}
|
||||||
|
@endif
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue