public function getIndex($group = null) { if (isset($group)) { $group = Group::find($group); $allTranslations = Translation::where('group_id', $group->id)->orderBy('key', 'asc')->get(); } else { $allTranslations = Translation::where('group_id', $group)->orderBy('key', 'asc')->get(); } $locales = Locale::all(); $groups = Group::groupBy('label'); $excludedGroups = $this->manager->getConfig('exclude_groups'); if ($excludedGroups) { $groups->whereNotIn('label', $excludedGroups); } $groups = $groups->lists('id', 'label'); if ($groups instanceof Collection) { $groups = $groups->all(); } return view('translation-manager::index')->with('allTranslations', $allTranslations)->with('locales', $locales)->with('groups', $groups)->with('group', $group)->with('editUrl', action('\\camdjn\\TranslationManager\\Controller@postEdit', [$group]))->with('deleteEnabled', $this->manager->getConfig('delete_enabled')); }
protected function makeTree($translations) { $array = array(); foreach ($translations as $translation) { $locale = Locale::find($translation->locale_id); array_set($array[$locale->label][$translation->group->label], $translation->key, $translation->value); } return $array; }