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('/\
/', $content, $matchedElement); $codes = ""; if ($matchedElement) { $codes .= "{$matchedElement[0]} @if(permissionCheck('can_have_downline') && checkUserPermission(\$staff->user, 'mlm-downline.index')) id) }}\" class=\"dropdown-item\">Downline @endif "; $appendContent = preg_replace('/\
/', $codes, $content); file_put_contents($masterPath, $appendContent, LOCK_EX); } } } }