copyLangFile(); $this->updateRegisterController(); $this->addCustomerRegisterStepForm(); //$this->updateStripePayment(); } public static function copyLangFile() { $langFile = module_path('RegistrationFormSteps', 'Resources/lang/default/member_register.php'); if (file_exists($langFile)) { File::copy($langFile, resource_path('lang/default/member_register.php')); } } public function updateRegisterController() { $path = app_path('Http/Controllers/Auth/RegisterController.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/isModuleActive\(\'RegistrationFormSteps\'\)/", $content)) { $matches = null; preg_match('/[.\s\S]+function create\([.\s\S]+?{[.\s\S]+?referral_code[.\s\S]+?}[.\s\S]+?}/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = "\n\n\t\tif(isModuleActive('RegistrationFormSteps')){\n\t\t\t\$user->wti_data = json_encode(\$data->only('storefront', 'company_name', 'brand_name', 'accounts_payable_name', 'accounts_payable_email', 'marketing_contact_name', 'marketing_contact_email', 'company_address'));\n\t\t\t\$user->save();\n\t\t}\n\n"; $code .= $snippet; $content = preg_replace("/[.\s\S]+function create\([.\s\S]+?{[.\s\S]+?referral_code[.\s\S]+?}[.\s\S]+?}/", $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public static function addCustomerRegisterStepForm() { if (isModuleActive('StaffPortal')) { $path = module_path('StaffPortal', 'Resources/views/register.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('registrationformsteps::customer\.form'\)/", $content)) { $matches = null; preg_match("/@include\('staffportal::components\._customer_register_form'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('RegistrationFormSteps')) @include('registrationformsteps::customer.form') @else @include('staffportal::components._customer_register_form') @endif "; $code = $snippet; $content = preg_replace("/@include\('staffportal::components\._customer_register_form'\)/", $code, $content); file_put_contents($path, $content); } } } } } public static function updateStripePayment() { $path = resource_path('views/frontend/amazy/partials/payments/stripe_payment.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/isset\(\$total_amount\)/", $content)) { $matches = null; preg_match('//', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isset(\$total_amount)) @else @endif"; $code = $snippet; $content = preg_replace('//', $code, $content); file_put_contents($path, $content); } } } } }