addCodesToMaster(); $this->addModalVueToMaster(); //$this->addCreateStudioToMenu(); $this->addBootstrapIconToHead(); $this->addGenerateTokenToLoginController(); } public function addCodesToMaster() { $masterPath = resource_path('/views/backEnd/master.blade.php'); if (file_exists($masterPath)) { $content = file_get_contents($masterPath); $elementExists = null; preg_match("/window.authToken/", $content, $elementExists); if ($elementExists) return; $matchedElement = null; preg_match("/\@include\('backEnd.partials._scripts'\)\r\n/", $content, $matchedElement); $codes = ""; if ($matchedElement) { $codes .= " "; $codes .= $matchedElement[0]; $appendContent = preg_replace("/\@include\('backEnd.partials._scripts'\)\r\n/", $codes, $content); file_put_contents($masterPath, $appendContent, LOCK_EX); } } } public function addModalVueToMaster() { $masterPath = resource_path('/views/backEnd/master.blade.php'); if (file_exists($masterPath)) { $content = file_get_contents($masterPath); $elementExists = null; preg_match('/\
\<\/div\>/', $content, $elementExists); if ($elementExists) return; preg_match("/\@include\('backEnd.partials._footer'\)\r\n/", $content, $matchedElement); $codes = ""; if ($matchedElement) { $codes .= "
{$matchedElement[0]} "; $appendContent = preg_replace("/\@include\('backEnd.partials._footer'\)\r\n/", $codes, $content); file_put_contents($masterPath, $appendContent, LOCK_EX); } } } public function addCreateStudioToMenu() { $path = resource_path('/views/backEnd/partials/_menu.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); $elementExists = null; preg_match("/\@include\('studioplus::create-studio'\)\r\n/", $content, $elementExists); if ($elementExists) return; preg_match("/
/", $content, $matchedElement); $codes = ""; if ($matchedElement) { /*$codes = "
@include('studioplus::create-studio') ";*/ $codes = "
"; $appendContent = preg_replace("/
/", $codes, $content); file_put_contents($path, $appendContent, LOCK_EX); } } } public function addBootstrapIconToHead() { $path = resource_path('/views/backEnd/partials/_head.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); $elementExists = null; preg_match("/\/", $content, $elementExists); if ($elementExists) return; preg_match("/\ "; $appendContent = preg_replace("/\/", $codes, $content); file_put_contents($path, $appendContent, LOCK_EX); } } } public function addGenerateTokenToLoginController() { $path = app_path('Http/Controllers/Auth/LoginController.php'); if (file_exists($path)) { $content = file_get_contents($path); $elementExists = null; preg_match("/\(new \\\Modules\\\StudioPlus\\\Services\\\HandleAuthToken\)->generateToken\(\);/", $content, $elementExists); if ($elementExists) return; preg_match("/return \\\$this->sendLoginResponse\(\\\$request\)/", $content, $matchedElement); $codes = ""; if ($matchedElement) { $codes = "(new \Modules\StudioPlus\Services\HandleAuthToken)->generateToken(); return \$this->sendLoginResponse(\$request);"; $appendContent = preg_replace("/return \\\$this->sendLoginResponse\(\\\$request\);/", $codes, $content); file_put_contents($path, $appendContent, LOCK_EX); } } } }