Fix backend code styling

This commit is contained in:
MakingCG
2021-06-15 16:37:41 +00:00
committed by GitHub Actions
parent 24676e2392
commit cb99e105c0
2 changed files with 93 additions and 94 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,4 @@
<?php <?php
namespace App\Http\Controllers\App; namespace App\Http\Controllers\App;
use Schema; use Schema;
@@ -65,7 +64,7 @@ class SetupWizardController extends Controller
*/ */
public function setup_database(StoreDatabaseCredentialsRequest $request) public function setup_database(StoreDatabaseCredentialsRequest $request)
{ {
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
try { try {
// Set temporary database connection // Set temporary database connection
config(['database.connections.test.driver' => $request->connection]); config(['database.connections.test.driver' => $request->connection]);
@@ -85,11 +84,11 @@ class SetupWizardController extends Controller
setEnvironmentValue([ setEnvironmentValue([
'DB_CONNECTION' => $request->connection, 'DB_CONNECTION' => $request->connection,
'DB_HOST' => $request->host, 'DB_HOST' => $request->host,
'DB_PORT' => $request->port, 'DB_PORT' => $request->port,
'DB_DATABASE' => $request->name, 'DB_DATABASE' => $request->name,
'DB_USERNAME' => $request->username, 'DB_USERNAME' => $request->username,
'DB_PASSWORD' => $request->password, 'DB_PASSWORD' => $request->password,
]); ]);
Artisan::call('config:cache'); Artisan::call('config:cache');
@@ -105,7 +104,7 @@ class SetupWizardController extends Controller
// Store setup wizard progress // Store setup wizard progress
Setting::forceCreate([ Setting::forceCreate([
'name' => 'setup_wizard_database', 'name' => 'setup_wizard_database',
'value' => 1, 'value' => 1,
]); ]);
@@ -120,7 +119,7 @@ class SetupWizardController extends Controller
*/ */
public function store_stripe_credentials(StoreStripeCredentialsRequest $request) public function store_stripe_credentials(StoreStripeCredentialsRequest $request)
{ {
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
// Create stripe instance // Create stripe instance
$stripe = Stripe::make($request->secret, '2020-03-02'); $stripe = Stripe::make($request->secret, '2020-03-02');
@@ -135,30 +134,30 @@ class SetupWizardController extends Controller
// Set settings // Set settings
collect([ collect([
[ [
'name' => 'stripe_currency', 'name' => 'stripe_currency',
'value' => $request->currency, 'value' => $request->currency,
], ],
[ [
'name' => 'payments_configured', 'name' => 'payments_configured',
'value' => 1, 'value' => 1,
], ],
[ [
'name' => 'payments_active', 'name' => 'payments_active',
'value' => 1, 'value' => 1,
], ],
])->each(function ($col) { ])->each(function ($col) {
Setting::forceCreate([ Setting::forceCreate([
'name' => $col['name'], 'name' => $col['name'],
'value' => $col['value'], 'value' => $col['value'],
]); ]);
}); });
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
// Set stripe credentials to .env // Set stripe credentials to .env
setEnvironmentValue([ setEnvironmentValue([
'CASHIER_CURRENCY' => $request->currency, 'CASHIER_CURRENCY' => $request->currency,
'STRIPE_KEY' => $request->key, 'STRIPE_KEY' => $request->key,
'STRIPE_SECRET' => $request->secret, 'STRIPE_SECRET' => $request->secret,
'STRIPE_WEBHOOK_SECRET' => $request->webhookSecret, 'STRIPE_WEBHOOK_SECRET' => $request->webhookSecret,
]); ]);
@@ -180,45 +179,45 @@ class SetupWizardController extends Controller
// Get options // Get options
collect([ collect([
[ [
'name' => 'billing_phone_number', 'name' => 'billing_phone_number',
'value' => $request->billing_phone_number, 'value' => $request->billing_phone_number,
], ],
[ [
'name' => 'billing_postal_code', 'name' => 'billing_postal_code',
'value' => $request->billing_postal_code, 'value' => $request->billing_postal_code,
], ],
[ [
'name' => 'billing_vat_number', 'name' => 'billing_vat_number',
'value' => $request->billing_vat_number, 'value' => $request->billing_vat_number,
], ],
[ [
'name' => 'billing_address', 'name' => 'billing_address',
'value' => $request->billing_address, 'value' => $request->billing_address,
], ],
[ [
'name' => 'billing_country', 'name' => 'billing_country',
'value' => $request->billing_country, 'value' => $request->billing_country,
], ],
[ [
'name' => 'billing_state', 'name' => 'billing_state',
'value' => $request->billing_state, 'value' => $request->billing_state,
], ],
[ [
'name' => 'billing_city', 'name' => 'billing_city',
'value' => $request->billing_city, 'value' => $request->billing_city,
], ],
[ [
'name' => 'billing_name', 'name' => 'billing_name',
'value' => $request->billing_name, 'value' => $request->billing_name,
], ],
])->each(function ($col) { ])->each(function ($col) {
Setting::forceCreate([ Setting::forceCreate([
'name' => $col['name'], 'name' => $col['name'],
'value' => $col['value'], 'value' => $col['value'],
]); ]);
}); });
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
Artisan::call('config:cache'); Artisan::call('config:cache');
} }
@@ -248,49 +247,49 @@ class SetupWizardController extends Controller
*/ */
public function store_environment_setup(StoreEnvironmentSetupRequest $request) public function store_environment_setup(StoreEnvironmentSetupRequest $request)
{ {
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
$drivers = [ $drivers = [
'local' => [ 'local' => [
'FILESYSTEM_DRIVER' => 'local', 'FILESYSTEM_DRIVER' => 'local',
], ],
's3' => [ 's3' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'AWS_ACCESS_KEY_ID' => $request->storage['key'] ?? null,
'AWS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null,
'AWS_DEFAULT_REGION' => $request->storage['region'] ?? null,
'AWS_BUCKET' => $request->storage['bucket'] ?? null,
],
'spaces' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'DO_SPACES_KEY' => $request->storage['key'] ?? null,
'DO_SPACES_SECRET' => $request->storage['secret'] ?? null,
'DO_SPACES_ENDPOINT' => $request->storage['endpoint'] ?? null,
'DO_SPACES_REGION' => $request->storage['region'] ?? null,
'DO_SPACES_BUCKET' => $request->storage['bucket'] ?? null,
],
'wasabi' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null, 'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'WASABI_KEY' => $request->storage['key'] ?? null, 'AWS_ACCESS_KEY_ID' => $request->storage['key'] ?? null,
'WASABI_SECRET' => $request->storage['secret'] ?? null, 'AWS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null,
'WASABI_ENDPOINT' => $request->storage['endpoint'] ?? null, 'AWS_DEFAULT_REGION' => $request->storage['region'] ?? null,
'WASABI_REGION' => $request->storage['region'] ?? null, 'AWS_BUCKET' => $request->storage['bucket'] ?? null,
'WASABI_BUCKET' => $request->storage['bucket'] ?? null, ],
'spaces' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'DO_SPACES_KEY' => $request->storage['key'] ?? null,
'DO_SPACES_SECRET' => $request->storage['secret'] ?? null,
'DO_SPACES_ENDPOINT' => $request->storage['endpoint'] ?? null,
'DO_SPACES_REGION' => $request->storage['region'] ?? null,
'DO_SPACES_BUCKET' => $request->storage['bucket'] ?? null,
],
'wasabi' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'WASABI_KEY' => $request->storage['key'] ?? null,
'WASABI_SECRET' => $request->storage['secret'] ?? null,
'WASABI_ENDPOINT' => $request->storage['endpoint'] ?? null,
'WASABI_REGION' => $request->storage['region'] ?? null,
'WASABI_BUCKET' => $request->storage['bucket'] ?? null,
], ],
'backblaze' => [ 'backblaze' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null, 'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'BACKBLAZE_KEY' => $request->storage['key'] ?? null, 'BACKBLAZE_KEY' => $request->storage['key'] ?? null,
'BACKBLAZE_SECRET' => $request->storage['secret'] ?? null, 'BACKBLAZE_SECRET' => $request->storage['secret'] ?? null,
'BACKBLAZE_ENDPOINT' => $request->storage['endpoint'] ?? null, 'BACKBLAZE_ENDPOINT' => $request->storage['endpoint'] ?? null,
'BACKBLAZE_REGION' => $request->storage['region'] ?? null, 'BACKBLAZE_REGION' => $request->storage['region'] ?? null,
'BACKBLAZE_BUCKET' => $request->storage['bucket'] ?? null, 'BACKBLAZE_BUCKET' => $request->storage['bucket'] ?? null,
], ],
'oss' => [ 'oss' => [
'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null, 'FILESYSTEM_DRIVER' => $request->storage['driver'] ?? null,
'OSS_ACCESS_KEY_ID' => $request->storage['key'] ?? null, 'OSS_ACCESS_KEY_ID' => $request->storage['key'] ?? null,
'OSS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null, 'OSS_SECRET_ACCESS_KEY' => $request->storage['secret'] ?? null,
'OSS_ENDPOINT' => $request->storage['endpoint'] ?? null, 'OSS_ENDPOINT' => $request->storage['endpoint'] ?? null,
'OSS_REGION' => $request->storage['region'] ?? null, 'OSS_REGION' => $request->storage['region'] ?? null,
'OSS_BUCKET' => $request->storage['bucket'] ?? null, 'OSS_BUCKET' => $request->storage['bucket'] ?? null,
], ],
]; ];
@@ -302,11 +301,11 @@ class SetupWizardController extends Controller
// Store credentials for mail // Store credentials for mail
// TODO: add options for mailgun // TODO: add options for mailgun
setEnvironmentValue([ setEnvironmentValue([
'MAIL_DRIVER' => $request->mail['driver'], 'MAIL_DRIVER' => $request->mail['driver'],
'MAIL_HOST' => $request->mail['host'], 'MAIL_HOST' => $request->mail['host'],
'MAIL_PORT' => $request->mail['port'], 'MAIL_PORT' => $request->mail['port'],
'MAIL_USERNAME' => $request->mail['username'], 'MAIL_USERNAME' => $request->mail['username'],
'MAIL_PASSWORD' => $request->mail['password'], 'MAIL_PASSWORD' => $request->mail['password'],
'MAIL_ENCRYPTION' => $request->mail['encryption'], 'MAIL_ENCRYPTION' => $request->mail['encryption'],
]); ]);
@@ -326,61 +325,61 @@ class SetupWizardController extends Controller
// Get options // Get options
collect([ collect([
[ [
'name' => 'app_title', 'name' => 'app_title',
'value' => $request->title, 'value' => $request->title,
], ],
[ [
'name' => 'app_description', 'name' => 'app_description',
'value' => $request->description, 'value' => $request->description,
], ],
[ [
'name' => 'app_logo', 'name' => 'app_logo',
'value' => store_system_image($request, 'logo'), 'value' => store_system_image($request, 'logo'),
], ],
[ [
'name' => 'app_logo_horizontal', 'name' => 'app_logo_horizontal',
'value' => store_system_image($request, 'logo_horizontal'), 'value' => store_system_image($request, 'logo_horizontal'),
], ],
[ [
'name' => 'app_favicon', 'name' => 'app_favicon',
'value' => store_system_image($request, 'favicon'), 'value' => store_system_image($request, 'favicon'),
], ],
[ [
'name' => 'app_og_image', 'name' => 'app_og_image',
'value' => store_system_image($request, 'og_image'), 'value' => store_system_image($request, 'og_image'),
], ],
[ [
'name' => 'app_touch_icon', 'name' => 'app_touch_icon',
'value' => store_system_image($request, 'touch_icon'), 'value' => store_system_image($request, 'touch_icon'),
], ],
[ [
'name' => 'google_analytics', 'name' => 'google_analytics',
'value' => $request->googleAnalytics, 'value' => $request->googleAnalytics,
], ],
[ [
'name' => 'contact_email', 'name' => 'contact_email',
'value' => $request->contactMail, 'value' => $request->contactMail,
], ],
[ [
'name' => 'registration', 'name' => 'registration',
'value' => $request->userRegistration, 'value' => $request->userRegistration,
], ],
[ [
'name' => 'storage_limitation', 'name' => 'storage_limitation',
'value' => $request->storageLimitation, 'value' => $request->storageLimitation,
], ],
[ [
'name' => 'storage_default', 'name' => 'storage_default',
'value' => $request->defaultStorage ?? 5, 'value' => $request->defaultStorage ?? 5,
], ],
])->each(function ($col) { ])->each(function ($col) {
Setting::forceCreate([ Setting::forceCreate([
'name' => $col['name'], 'name' => $col['name'],
'value' => $col['value'], 'value' => $col['value'],
]); ]);
}); });
if (!app()->runningUnitTests()) { if (! app()->runningUnitTests()) {
setEnvironmentValue([ setEnvironmentValue([
'APP_NAME' => Str::camel($request->title), 'APP_NAME' => Str::camel($request->title),
]); ]);
@@ -400,18 +399,18 @@ class SetupWizardController extends Controller
// Validate request // Validate request
// TODO: validator do requestu // TODO: validator do requestu
$request->validate([ $request->validate([
'email' => 'required|string|email|unique:users', 'email' => 'required|string|email|unique:users',
'password' => 'required|string|min:6|confirmed', 'password' => 'required|string|min:6|confirmed',
'name' => 'required|string', 'name' => 'required|string',
'purchase_code' => 'required|string', 'purchase_code' => 'required|string',
'license' => 'required|string', 'license' => 'required|string',
'avatar' => 'sometimes|file', 'avatar' => 'sometimes|file',
]); ]);
// Create user // Create user
$user = User::forceCreate([ $user = User::forceCreate([
'role' => 'admin', 'role' => 'admin',
'email' => $request->email, 'email' => $request->email,
'password' => bcrypt($request->password), 'password' => bcrypt($request->password),
]); ]);
@@ -419,26 +418,26 @@ class SetupWizardController extends Controller
->settings() ->settings()
->create([ ->create([
'storage_capacity' => get_setting('storage_default') ?? 5, 'storage_capacity' => get_setting('storage_default') ?? 5,
'avatar' => store_avatar($request, 'avatar'), 'avatar' => store_avatar($request, 'avatar'),
'name' => $request->name, 'name' => $request->name,
]); ]);
collect([ collect([
[ [
'name' => 'setup_wizard_success', 'name' => 'setup_wizard_success',
'value' => 1, 'value' => 1,
], ],
[ [
'name' => 'license', 'name' => 'license',
'value' => $request->license, 'value' => $request->license,
], ],
[ [
'name' => 'purchase_code', 'name' => 'purchase_code',
'value' => $request->purchase_code, 'value' => $request->purchase_code,
], ],
])->each(function ($col) { ])->each(function ($col) {
Setting::forceCreate([ Setting::forceCreate([
'name' => $col['name'], 'name' => $col['name'],
'value' => $col['value'], 'value' => $col['value'],
]); ]);
}); });