addOrdersTabToProfile(); //$this->addOrdersTabToCustomerDetails(); $this->updateVericyCsrftoken(); $this->addCartToHeader(); $this->addCartToSubMenu(); } public function addCartToHeader() { $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\('wtialacarte::components\.cart_mobile'\)/", $content)) { $matches = null; preg_match('/[.\s\S]+?<\/a>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('WTIALaCarte')) @include('wtialacarte::components.cart_mobile') @else
{{__('common.cart')}} ({{getNumberTranslate(\$items)}})
@endif "; $code = $snippet; $content = preg_replace('/[.\s\S]+?<\/a>/', $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addCartToSubMenu() { $path = resource_path('/views/frontend/amazy/partials/_submenu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('wtialacarte::components\.cart_web'\)/", $content)) { $matches = null; preg_match('/[.\s\S]+?<\/a>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('WTIALaCarte')) @include('wtialacarte::components.cart_web') @else {{-- \"\" --}} {{ __('common.cart') }} ({{getNumberTranslate(\$items)}}) @endif "; $code = $snippet; $content = preg_replace('/[.\s\S]+?<\/a>/', $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addOrdersTabToProfile() { $path = resource_path('/views/frontend/amazy/pages/profile/profile.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('wtialacarte::components\.orders_tab'\)/", $content)) { $matches = null; preg_match('//', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('WTIALaCarte')) @include('wtialacarte::components.orders_tab') @endif "; $code = $code.$snippet; $content = preg_replace('//', $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match("/@include\('wtialacarte::components\.orders_tab_content'\)/", $content)) { $matches = null; preg_match('/
[.\s\S]+?<\/div>/', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('WTIALaCarte')) @include('wtialacarte::components.orders_tab_content') @endif "; $code = $code.$snippet; $content = preg_replace('/
[.\s\S]+?<\/div>/', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addOrdersTabToCustomerDetails() { $path = module_path('Customer', 'Resources/views/customers/show_details.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('wtialacarte::components\.customer_orders_tab_content'\)/", $content)) { $matches = null; preg_match('//', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('WTIALaCarte')) @include('wtialacarte::components.customer_orders_tab_content') @endif "; $code .= $snippet; $content = preg_replace('//', $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function updateVericyCsrftoken() { $path = app_path('Http/Middleware/VerifyCsrfToken.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/a-la-carte\/webhooks\/stripe/", $content)) { $matches = null; preg_match("/\'search\'\,/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = "'search',\n\t\t'/a-la-carte/webhooks/stripe',"; $code = $snippet; $content = preg_replace("/\'search\'\,/", $code, $content); //file_put_contents($path, $content); $update = true; } if ($update) { file_put_contents($path, $content); } } } } }