addLoginTab(); $this->addLoginTabForm(); $this->updateSidebar(); $this->hidePlusMenuForStaff(); $this->addTooltipsToMenus(); $this->fixStaffSidebarMenuOrder(); $this->updateCreateDashboardColorPickers(); $this->updateEditDashboardColorPickers(); if (isModuleActive('JobPortal')) { $this->updateDashboard(); $this->addMainMenuToAdminDashboard(); $this->addMenuColorSettings(); $this->updateProfileMenu(); } $this->addUsernameFieldToStaffCreateForm(); $this->addUsernameFieldToStaffEditForm(); $this->updateUserRepository(); $this->updateStaffRequest(); $this->updateLoginController(); //$this->addMobileHeaderForStaffLogin(); $this->updateRegisterController(); $this->addUsernameSupportToProfilePage(); $this->updateUsernameSupportInCustomerController(); $this->addUsernameFieldToCandidateProfileForm(); $this->updateUsernameSupportInCandidateProfileController(); $this->addFrontendProfileMenu(); $this->copyLangFile(); $this->addUsernameFieldToStaffRegister(); $this->updateUserModel(); $this->addJobPortalMenu(); $this->addEmailSettingsToGeneralSettings(); $this->updateCustomerDetails(); } public static function addLoginTab() { if (isModuleActive('FrontendCMS')) { $path = module_path('FrontendCMS', 'Resources/views/login-page/index.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._login_tab'\)/", $content)) { $matches = null; preg_match("/@if\(isModuleActive\('MultiVendor'\)\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._login_tab') @endif "; $code = $snippet.$code; $content = preg_replace("/@if\(isModuleActive\('MultiVendor'\)\)/", $code, $content); file_put_contents($path, $content); } } } } } public static function addLoginTabForm() { if (isModuleActive('FrontendCMS')) { $path = module_path('FrontendCMS', 'Resources/views/login-page/components/form.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._login_tab_form'\)/", $content)) { $matches = null; preg_match('/
/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._login_tab_form') @endif "; $code = $snippet.$code; $content = preg_replace('/
/', $code, $content); file_put_contents($path, $content); } } } } } public function updateSidebar() { //$theme = app('theme'); //if ($theme) { //$theme_name = app('theme')->folder_path; $path = resource_path('views/backEnd/partials/_sidebar.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/FEMD/", $content)) { $matches = null; preg_match('/[.\s\S]+?<\/span>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " {{-- FEMD --}} @php \$count = 0; @endphp @if(\$section->children->count()) @foreach(\$section->children as \$menu) @if(!@\$menu->backendMenu->module or isModuleActive(@\$menu->backendMenu->module)) @if(@\$menu->backendMenu->route == 'payment_gateway.index' && auth()->user()->role->type == 'seller' && !app('general_setting')->seller_wise_payment) @continue @elseif(permissionCheck(@\$menu->backendMenu->route)) @php \$count++; @endphp @endif @endif @endforeach @endif @if(\$count > 0) " .$code. " @endif "; $code = $snippet; $content = preg_replace('/[.\s\S]+?<\/span>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } //} } public function updateDashboard() { //$theme = app('theme'); //if ($theme) { //$theme_name = app('theme')->folder_path; $path = resource_path('views/backEnd/dashboard.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._dashboard_cards'\)/", $content)) { $matches = null; preg_match('/@if \(permissionCheck\(\'widget_card\'\)\)[\r\n]*[\s]+?
/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._dashboard_cards') @endif "; $code = $snippet.$code; $content = preg_replace('/@if \(permissionCheck\(\'widget_card\'\)\)[\r\n]*[\s]+?
/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } //} } public function addMainMenuToAdminDashboard() { //$theme = app('theme'); //if ($theme) { //$theme_name = app('theme')->folder_path; $path = resource_path('views/backEnd/master.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._mega_menu'\)/", $content)) { $matches = null; preg_match("/@include\('backEnd\.partials\._menu'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._mega_menu') @endif "; $code = $snippet.$code; $content = preg_replace("/@include\('backEnd\.partials\._menu'\)/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } //} } public static function addMenuColorSettings() { if (isModuleActive('Appearance')) { $path = module_path('Appearance', 'Resources/views/theme_color/index.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._color_settings'\)/", $content)) { $matches = null; preg_match("/@error\('danger_color'\)[.\s\S]+?<\/div>[.\s\S]+?<\/div>/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._color_settings') @endif "; $code .= $snippet; $content = preg_replace("/@error\('danger_color'\)[.\s\S]+?<\/div>[.\s\S]+?<\/div>/", $code, $content); file_put_contents($path, $content); } } } } } public function updateProfileMenu() { $path = resource_path('views/backEnd/partials/_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@if \(isModuleActive\('StaffPortal'\)[.\s\S]+?'staff'\)/", $content)) { $matches = null; preg_match('/{{__[.\s\S]+?<\/a>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal') && auth()->user()->role->type == 'staff') {{__('customer_panel.my_profile')}} @else {{__('customer_panel.my_profile')}} @endif "; $code = $snippet; $content = preg_replace('/{{__[.\s\S]+?<\/a>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function hidePlusMenuForStaff() { $path = resource_path('views/backEnd/partials/_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@if.+'affiliate'.+'customer'.+'staff'\)/", $content)) { $matches = null; preg_match("/@if.+'affiliate'.+'customer'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if(auth()->user()->role->type != 'affiliate' && auth()->user()->role->type != 'customer' && auth()->user()->role->type != 'staff') "; $code = $snippet; $content = preg_replace("/@if.+'affiliate'.+'customer'\)/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addTooltipsToMenus() { $path = resource_path('views/backEnd/partials/_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match('/<\/i>/', $content)) { $matches = null; preg_match('/<\/i>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " "; $code = $snippet; $content = preg_replace('/<\/i>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match('/<\/i>/', $content)) { $matches = null; preg_match('/<\/i>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._tooltips_script') @endif "; $code = $snippet; $content = preg_replace('/<\/i>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public static function fixStaffSidebarMenuOrder() { if (isModuleActive('SidebarManager')) { $path = module_path('SidebarManager', 'Traits/SidebarTrait.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/isModuleActive\('StaffPortal'\)/", $content)) { $matches = null; preg_match('/foreach\(\$backend_menu_not_exsist as \$menu\){[.\s\S]+?BackendmenuUser::create[.\s\S]+?}/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " if (isModuleActive('StaffPortal')) { \Modules\StaffPortal\Services\CommonService::processMenus(\$backend_menu_not_exsist); } /* ".$code." */ "; $code = $snippet; $content = preg_replace('/foreach\(\$backend_menu_not_exsist as \$menu\){[.\s\S]+?BackendmenuUser::create[.\s\S]+?}/', $code, $content); file_put_contents($path, $content); } } } } } public function updateCreateDashboardColorPickers() { if (isModuleActive('Appearance')) { $path = module_path('Appearance', 'Resources/views/color/create.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match('/\.color-picker-container/', $content)) { $matches = null; preg_match('//', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " "; $code .= $snippet; $content = preg_replace('//', $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._background_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._base_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('base_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._base_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('base_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._solid_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('solid_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._solid_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('solid_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_one_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_one'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._gradient_one_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_one'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_two_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_two'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._gradient_two_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_two'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_three_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_three'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._gradient_three_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_three'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._scroll_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('scroll_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._scroll_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('scroll_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._text_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_white_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_white'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._text_white_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_white'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_white_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_white'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._background_white_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_white'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_black_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_black'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._text_black_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_black'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_black_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_black'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._background_black_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_black'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._border_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('border_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._border_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('border_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._input_background_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('input_background'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._input_background_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('input_background'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._success_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('success_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._success_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('success_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._warning_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('warning_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._warning_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('warning_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._danger_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('danger_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._danger_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('danger_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._script'\)/", $content)) { $matches = null; preg_match("/@endpush/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components.dashboard_pickers._script') @endif "; $code = $snippet . $code; $content = preg_replace("/@endpush/", $code, $content); $update = true; } } if (!preg_match("/primary_input_field d-none/", $content)) { $matches = null; preg_match("/primary_input_field/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = "primary_input_field d-none"; $code = $snippet; $content = preg_replace("/primary_input_field/", $code, $content); $update = true; } } if (!preg_match('/id="title" class="primary_input_field"/', $content)) { $matches = null; preg_match('/id="title" class="primary_input_field d-none"/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = 'id="title" class="primary_input_field"'; $code = $snippet; $content = preg_replace('/id="title" class="primary_input_field d-none"/', $code, $content); $update = true; } } if (!preg_match('/class="primary_input_field" type="number" id="toastr_time"/', $content)) { $matches = null; preg_match('/class="primary_input_field d-none" type="number" id="toastr_time"/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = 'class="primary_input_field" type="number" id="toastr_time"'; $code = $snippet; $content = preg_replace('/class="primary_input_field d-none" type="number" id="toastr_time"/', $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } } public function updateEditDashboardColorPickers() { if (isModuleActive('Appearance')) { $path = module_path('Appearance', 'Resources/views/color/edit.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match('/\.color-picker-container/', $content)) { $matches = null; preg_match('//', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " "; $code .= $snippet; $content = preg_replace('//', $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._background_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._base_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('base_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._base_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('base_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._solid_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('solid_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._solid_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('solid_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_one_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_one'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._gradient_one_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_one'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_two_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_two'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._gradient_two_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_two'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._gradient_three_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('gradient_color_three'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._gradient_three_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('gradient_color_three'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._scroll_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('scroll_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._scroll_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('scroll_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._text_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_white_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_white'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._text_white_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_white'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_white_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_white'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._background_white_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_white'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._text_black_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('text_black'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._text_black_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('text_black'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._background_black_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('background_black'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._background_black_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('background_black'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._border_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('border_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._border_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('border_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._input_background_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('input_background'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._input_background_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('input_background'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._success_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('success_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._success_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('success_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._warning_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('warning_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._warning_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('warning_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._danger_color_picker'\)/", $content)) { $matches = null; preg_match("/@error\('danger_color'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._danger_color_picker') @endif "; $code = $snippet . $code; $content = preg_replace("/@error\('danger_color'\)/", $code, $content); $update = true; } } if (!preg_match("/@include\('staffportal::components\.dashboard_pickers._script'\)/", $content)) { $matches = null; preg_match("/@endpush/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('staffportal')) @include('staffportal::components.dashboard_pickers._script') @endif "; $code = $snippet . $code; $content = preg_replace("/@endpush/", $code, $content); $update = true; } } if (!preg_match("/primary_input_field d-none/", $content)) { $matches = null; preg_match("/primary_input_field/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = "primary_input_field d-none"; $code = $snippet; $content = preg_replace("/primary_input_field/", $code, $content); $update = true; } } if (!preg_match('/id="title" class="primary_input_field"/', $content)) { $matches = null; preg_match('/id="title" class="primary_input_field d-none"/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = 'id="title" class="primary_input_field"'; $code = $snippet; $content = preg_replace('/id="title" class="primary_input_field d-none"/', $code, $content); $update = true; } } if (!preg_match('/class="primary_input_field" type="number" id="toastr_time"/', $content)) { $matches = null; preg_match('/class="primary_input_field d-none" type="number" id="toastr_time"/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = 'class="primary_input_field" type="number" id="toastr_time"'; $code = $snippet; $content = preg_replace('/class="primary_input_field d-none" type="number" id="toastr_time"/', $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } } public function addUsernameFieldToStaffCreateForm() { $path = resource_path('views/backEnd/staffs/create.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/\@include\('staffportal::components\._username_field'\)/", $content)) { $matches = null; preg_match('/{{\$errors->first\(\'phone\'\)}}<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._username_field') @endif "; $code = $code.$snippet; $content = preg_replace('/{{\$errors->first\(\'phone\'\)}}<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addUsernameFieldToStaffEditForm() { $path = resource_path('views/backEnd/staffs/edit.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/\@include\('staffportal::components\._username_field'\)/", $content)) { $matches = null; preg_match('/{{\$errors->first\(\'phone\'\)}}<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._username_field') @endif "; $code = $code.$snippet; $content = preg_replace('/{{\$errors->first\(\'phone\'\)}}<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function updateUserRepository() { $path = app_path('Repositories/UserRepository.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match('/\(isModuleActive\(\'StaffPortal\'\)\)/', $content)) { $matches = null; preg_match('/\$user->username = \$data\[\'phone\'\];/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " if (isModuleActive('StaffPortal')) { \$user->phone = \$data['phone']; \$user->username = \$data['username']; } "; $code = $code.$snippet; $content = preg_replace('/\$user->username = \$data\[\'phone\'\];/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function updateStaffRequest() { $path = app_path('Http/Requests/StaffRequest.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match('/\(isModuleActive\(\'StaffPortal\'\)\)/', $content)) { $matches = null; preg_match('/"phone" => "nullable\|unique:users,username,"\.\$request->user_id,/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " \"phone\" => \"nullable|unique:users,phone,\".\\\$request->user_id, \"username\" => \"required|unique:users,username,\".\\\$request->user_id, "; $code = $snippet; $content = preg_replace('/"phone" => "nullable\|unique:users,username,"\.\$request->user_id,/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function updateLoginController() { $path = app_path('Http/Controllers/Auth/LoginController.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/\\\$q->where\('type', 'customer'\)->orWhere\('type', 'staff'\)/", $content)) { $matches = null; preg_match("/\\\$q->where\('type', 'customer'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = "\$q->where('type', 'customer')->orWhere('type', 'staff')"; $code = $snippet; $content = preg_replace("/\\\$q->where\('type', 'customer'\)/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addMobileHeaderForStaffLogin() { $path = resource_path('views/frontend/amazy/partials/_header.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._mobile_header'\)/", $content)) { $matches = null; preg_match("//", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._mobile_header') @endif "; $code .= $snippet; $content = preg_replace("//", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } 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\(\'StaffPortal\'\)\)/', $content)) { $matches = null; preg_match("/return view\(theme\('auth\.register'\),compact\('row','form_data','loginPageInfo'\)\);/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " if (isModuleActive('StaffPortal')) { return view('staffportal::register', compact('row', 'form_data', 'loginPageInfo')); } else { return view(theme('auth.register'),compact('row','form_data','loginPageInfo')); } "; $code = $snippet; $content = preg_replace("/return view\(theme\('auth\.register'\),compact\('row','form_data','loginPageInfo'\)\);/", $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match('/function create[.\s\S]+?\$user->job_category_data/', $content)) { $matches = null; preg_match("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?data\['job_type'\]\;/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " if(isModuleActive('StaffPortal')){ //POV VIDEOS FORM if(\$data['job_type'] == 17) { \$user->job_category_data = \$data->only('asin', 'video_creator', 'shipping_info', 'tracking_info', 'product_received', 'video_published'); } else if(\$data['job_type'] == 25) { \$user->job_category_data = \$data->only('asin', 'pov_video_link', 'date_scheduled', 'livestream_completed'); } } \$user->company_id = isset(\$company) ? \$company->id : null; "; $code = $code.$snippet; $content = preg_replace("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?data\['job_type'\]\;/", $code, $content); $update = true; } } if (!preg_match("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?if\(isModuleActive\('StaffPortal'\)\)\{[.\s\S]+?data\['job_type'\] \=\= 17\) {[.\s\S]+?\$data\[\'asin\'\]/", $content)) { $matches = null; preg_match("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?if\(isModuleActive\('StaffPortal'\)\)\{[.\s\S]+?data\['job_type'\] \=\= 17\) {[.\s\S]+?}/", $content, $matches); if (count($matches) > 0) { $code = str_replace("\$user->job_category_data = \$data->only('asin', 'video_creator', 'shipping_info', 'tracking_info', 'product_received', 'video_published');", " \$data['asin'] = explode(',', \$data['pov_asin']); \$user->job_category_data = \$data->only('asin', 'video_creator', 'shipping_info', 'tracking_info', 'product_received', 'video_published');",$matches[0]); $content = preg_replace("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?if\(isModuleActive\('StaffPortal'\)\)\{[.\s\S]+?data\['job_type'\] \=\= 17\) {[.\s\S]+?}/", $code, $content); $update = true; } } if (!preg_match('/function create[.\s\S]+?\$data\[\'product_names\'\]/', $content)) { $matches = null; preg_match("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?if\(isModuleActive\('StaffPortal'\)\)\{[.\s\S]+?data\['job_type'\] \=\= 25\) {[.\s\S]+?}/", $content, $matches); if (count($matches) > 0) { $code = str_replace("\$user->job_category_data = \$data->only('asin', 'pov_video_link', 'date_scheduled', 'livestream_completed');", " \$data['asin'] = explode(',', \$data['livestream_asin']); \$data['product_names'] = preg_split ('/\\r\\n|\\r|\\n/', \$data['product_names']); if(\$file = \$data->file('brand_logo')){ \$brand_logo = ImageStore::saveImage(\$file); \$data['sponsored_logo'] = \$brand_logo; } \$user->job_category_data = \$data->only('sponsored_live_shows','sponsored_asin','sponsored_logo','featured_total','asin','product_names','featured_item','pov_video_asin', 'pov_video_link', 'date_scheduled', 'livestream_completed');",$matches[0]); $content = preg_replace("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?if\(isModuleActive\('StaffPortal'\)\)\{[.\s\S]+?data\['job_type'\] \=\= 25\) {[.\s\S]+?}/", $code, $content); $update = true; } } if (!preg_match("/Company\:\:create\(/", $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('JobPortal') && \$role_id == 4){ \n\n\t\t\t\$company = \Modules\JobPortal\Entities\Company::create([\n\t\t\t\t'name' => \$data['company'],\n\t\t\t\t'owner_id' => \$user->id,\n\t\t\t\t'email' => \$data['email'],\n\t\t\t\t'phone' => \$data['[phone]'],\n\t\t\t\t'website' => \$data['website']\n\t\t\t]); \n\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 (!preg_match("/function create[.\s\S]+?\$user->company_name \=/", $content)) { $matches = null; preg_match("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?company \=/", $content, $matches); if (count($matches) > 0) { $code = str_replace("\$user->company =", "\$user->company_name =",$matches[0]); $content = preg_replace("/function create\([.\s\S]+?if\(isModuleActive\('WTISignupForms'\)\)\{[.\s\S]+?company \=/", $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addUsernameSupportToProfilePage() { $path = resource_path('views/backEnd/pages/customer_data/profile.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/\@include\('staffportal::components\._username_field2'\)/", $content)) { $matches = null; preg_match('/<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) @include('staffportal::components._username_field2') @endif "; $code = $code.$snippet; $content = preg_replace('/<\/span>[.\s\S]+?<\/div>[.\s\S]+?<\/div>/', $code, $content); //file_put_contents($path, $content); $update = true; } $matches = null; preg_match("/\\\$\('#error_avatar'\)\.text\(response\.responseJSON\.errors\.avatar\);/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) $('#error_username').text(response.responseJSON.errors.username); @endif "; $code = $code.$snippet; $content = preg_replace("/\\\$\('#error_avatar'\)\.text\(response\.responseJSON\.errors\.avatar\);/", $code, $content); //file_put_contents($path, $content); $update = true; } $matches = null; preg_match("/\\\$\('#error_avatar'\)\.text\(''\);/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('StaffPortal')) $('#error_username').text(''); @endif "; $code = $code.$snippet; $content = preg_replace("/\\\$\('#error_avatar'\)\.text\(''\);/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public static function updateUsernameSupportInCustomerController() { if (isModuleActive('Customer')) { $path = module_path('Customer', 'Http/Controllers/CustomerController.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/isModuleActive\('StaffPortal'\)/", $content)) { $matches = null; preg_match('/public function updateInfo\(Request \$request\)[.\s\S]+?{/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " if (isModuleActive('StaffPortal')) { \$ret = app(\Modules\StaffPortal\Services\CommonService::class)->updateInfo(\$request); if (\$ret) { return response()->json(\$ret); } else { return back(); } } "; $code .= $snippet; $content = preg_replace('/public function updateInfo\(Request \$request\)[.\s\S]+?{/', $code, $content); file_put_contents($path, $content); } } } } } public static function addUsernameFieldToCandidateProfileForm() { if (isModuleActive('JobPortalCandidate')) { $path = module_path('JobPortalCandidate', 'Resources/views/admin/candidate/form.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('staffportal::components\._username_field3'\)/", $content)) { $matches = null; preg_match('/