/** * @param $namespace string * @param $group string * @param $key string * * @param null $locale * @param bool $useLottery * @param bool $findOrNew * * @return \Vsch\TranslationManager\Models\Translation|null */ public function missingKey($namespace, $group, $key, $locale = null, $useLottery = false, $findOrNew = false) { $group = $namespace && $namespace !== '*' ? $namespace . '::' . $group : $group; if (!in_array($group, $this->config()['exclude_groups']) && $this->config()['log_missing_keys']) { $lottery = 1; if ($useLottery && $this->config()['missing_keys_lottery'] !== 1) { $lottery = Session::get($this->config()['persistent_prefix'] . 'lottery', ''); if ($lottery === '') { $lottery = rand(1, $this->config()['missing_keys_lottery']); Session::put($this->config()['persistent_prefix'] . 'lottery', $lottery); } } if ($lottery === 1) { $locale = $locale ?: $this->app['config']['app.locale']; if ($findOrNew) { $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key)); } else { $translation = Translation::firstOrCreate(array('locale' => $locale, 'group' => $group, 'key' => $key)); } return $translation; } } return null; }