private function setRoleLanguage($role, $locale, $text)
    {
        if (is_numeric($role)) {
            $role = $this->find($role);
        }

        if (!$role) {
            return;
        }

        $roleName = $role->snake_case_name;
        $languageFilePath = resource_path('lang/' . $locale . '/role.php');
        if (!file_exists($languageFilePath)) {
            throw new FileNotFoundException("resources/lang/{$locale}/role.php doesn't exist.");
        }
        $languageContent = file_get_contents($languageFilePath);

        $text = addslashes($text);
        $regexp = "/('roles'.*=>[\w\W]*)('{$roleName}'\s*=>\s*')(.+)'/";
        $replaceExp = "$1$2{$text}'";

        $languageContent = preg_replace($regexp, $replaceExp, $languageContent);

        file_put_contents($languageFilePath, $languageContent);
    }
private function setRoleLanguage($role, $locale, $text)
    {
        if (is_numeric($role)) {
            $role = $this->find($role);
        }

        if (!$role) {
            return;
        }

        $roleName = $role->snake_case_name;
        $languageFilePath = resource_path('lang/' . $locale . '/role.php');
        if (!file_exists($languageFilePath)) {
            throw new FileNotFoundException("resources/lang/{$locale}/role.php doesn't exist.");
        }
        $languageContent = file_get_contents($languageFilePath);

        $text = addslashes($text);
        $regexp = "/('roles'.*=>[\w\W]*)('{$roleName}'\s*=>\s*')(.+)'/";
        $replaceExp = "$1$2{$text}'";

        $languageContent = preg_replace($regexp, $replaceExp, $languageContent);

        file_put_contents($languageFilePath, $languageContent);
    }
private function setRoleLanguage ( $ role , $ locale , $ text ) { if ( is_numeric ( $ role ) ) { $ role = $ this -> find ( $ role ) ; } if ( ! $ role ) { return ; } $ roleName = $ role -> snake_case_name ; $ languageFilePath = resource_path ( 'lang/' . $ locale . '/role.php' ) ; if ( ! file_exists ( $ languageFilePath ) ) { throw new FileNotFoundException ( "resources/lang/{$locale}/role.php doesn't exist." ) ; } $ languageContent = file_get_contents ( $ languageFilePath ) ; $ text = addslashes ( $ text ) ; $ regexp = "/('roles'.*=>[\w\W]*)('{$roleName}'\s*=>\s*')(.+)'/" ; $ replaceExp = "$1$2{$text}'" ; $ languageContent = preg_replace ( $ regexp , $ replaceExp , $ languageContent ) ; file_put_contents ( $ languageFilePath , $ languageContent ) ; }
To update the role translated text
@param $role
@param $locale
@param $text
@throws FileNotFoundException
To update the role translated text