mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-01 17:17:12 -04:00
58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?php
|
|
namespace Modules\Customer\Services;
|
|
|
|
class AugmentationService
|
|
{
|
|
public function __construct() {
|
|
$this->updateUserModel();
|
|
}
|
|
|
|
public function updateUserModel() {
|
|
$path = app_path('Models/User.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
|
|
|
|
if (!preg_match("/CustomerTrait/", $content)) {
|
|
$matches = null;
|
|
preg_match('/[.\s\S]+Authenticatable[.\s\S]+?{/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "\n\n\tuse \Modules\Customer\Traits\CustomerTrait;";
|
|
$code .= $snippet;
|
|
$content = preg_replace("/[.\s\S]+Authenticatable[.\s\S]+?{/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if (!preg_match("/'company_details'/", $content)) {
|
|
$matches = null;
|
|
preg_match("/'name'/", $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "'name',\n\t\t'company_details'";
|
|
$code = $snippet;
|
|
$content = preg_replace("/'name'/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if (!preg_match("/'subscription_status'/", $content)) {
|
|
$matches = null;
|
|
preg_match("/'name'/", $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "'name',\n\t\t'subscription_status'";
|
|
$code = $snippet;
|
|
$content = preg_replace("/'name'/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
}
|
|
} |