mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-02 21:16:12 -04:00
37 lines
1.4 KiB
PHP
37 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\MLMDownline\Services;
|
|
|
|
class AugmentationService
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->addCodeToStaffIndexBlade();
|
|
}
|
|
|
|
public function addCodeToStaffIndexBlade()
|
|
{
|
|
$masterPath = resource_path('/views/backEnd/staffs/index.blade.php');
|
|
if (file_exists($masterPath)) {
|
|
$content = file_get_contents($masterPath);
|
|
$elementExists = null;
|
|
|
|
// Check added code if already exists
|
|
preg_match("/\@if\(permissionCheck\('can_have_downline'\)/", $content, $elementExists);
|
|
if ($elementExists) return;
|
|
|
|
preg_match('/\<div class\="dropdown-menu dropdown-menu-right" aria-labelledby\="dropdownMenu2"\>/', $content, $matchedElement);
|
|
$codes = "";
|
|
if ($matchedElement) {
|
|
$codes .= "{$matchedElement[0]}
|
|
@if(permissionCheck('can_have_downline') && checkUserPermission(\$staff->user, 'mlm-downline.index'))
|
|
<a href=\"{{ route('can_have_downline', \$staff->id) }}\" class=\"dropdown-item\">Downline</a>
|
|
@endif
|
|
";
|
|
$appendContent = preg_replace('/\<div class\="dropdown-menu dropdown-menu-right" aria-labelledby\="dropdownMenu2"\>/', $codes, $content);
|
|
file_put_contents($masterPath, $appendContent, LOCK_EX);
|
|
}
|
|
}
|
|
}
|
|
}
|