mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-01 08:16:55 -04:00
122 lines
4.6 KiB
PHP
122 lines
4.6 KiB
PHP
<?php
|
|
namespace Modules\Chat\Services;
|
|
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
class AugmentationService
|
|
{
|
|
public function __construct() {
|
|
$this->addHeaderMenu();
|
|
$this->updateProfileMenu();
|
|
//$this->updateEnv();
|
|
$this->updateComposer();
|
|
}
|
|
|
|
public static function addHeaderMenu() {
|
|
$path = resource_path('views/backEnd/partials/_menu.blade.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/@include\('chat::components\._menu'\)/", $content)) {
|
|
$matches = null;
|
|
preg_match('/<li class="scroll_notification_list">/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "
|
|
@if (isModuleActive('Chat'))
|
|
@include('chat::components._menu')
|
|
@endif
|
|
".$code;
|
|
$code = $snippet;
|
|
$content = preg_replace('/<li class="scroll_notification_list">/', $code, $content);
|
|
//file_put_contents($path, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function updateProfileMenu() {
|
|
/*$theme = app('theme');
|
|
if ($theme) {
|
|
$theme_name = app('theme')->folder_path;*/
|
|
$path = resource_path('views/frontend/amazy/pages/profile/partials/_menu.blade.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/@include\('chat::components\._dashboard_menu'\)/", $content)) {
|
|
$matches = null;
|
|
preg_match('/<li[.\s\S]+?{{url\(\'\/profile\'\)}}[.\s\S]+?<\/li>/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "
|
|
@if (isModuleActive('Chat'))
|
|
@include('chat::components._dashboard_menu')
|
|
@endif
|
|
";
|
|
$code = $code.$snippet;
|
|
$content = preg_replace('/<li[.\s\S]+?{{url\(\'\/profile\'\)}}[.\s\S]+?<\/li>/', $code, $content);
|
|
//file_put_contents($path, $content);
|
|
$update = true;
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
//}
|
|
}
|
|
|
|
public function updateEnv() {
|
|
$path = base_path('.env');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/BROADCAST_DRIVER=pusher/", $content)) {
|
|
$matches = null;
|
|
preg_match('/BROADCAST_DRIVER[.\S]+/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "BROADCAST_DRIVER=pusher";
|
|
$code = $snippet;
|
|
$content = preg_replace('/BROADCAST_DRIVER[.\S]+/', $code, $content);
|
|
//file_put_contents($path, $content);
|
|
$update = true;
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function updateComposer() {
|
|
$path = base_path('composer.json');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (preg_match("/\"gliterd\/laravel-backblaze-b2\":[.\s\S]+?,/", $content)) {
|
|
$matches = null;
|
|
preg_match('/\"gliterd\/laravel-backblaze-b2\":[.\s\S]+?,/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "";
|
|
$code = $snippet;
|
|
$content = preg_replace('/\"gliterd\/laravel-backblaze-b2\":[.\s\S]+?,/', $code, $content);
|
|
//file_put_contents($path, $content);
|
|
$update = true;
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |