/**
  * @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;
 }
 public function postEdit(HttpRequest $request, $group)
 {
     if (!in_array($group, $this->manager->getConfig('exclude_groups'))) {
         $name = $request->get('name');
         $value = $request->get('value');
         list($locale, $key) = explode('|', $name, 2);
         $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
         // strip off trailing spaces and eol's and &nbsps; that seem to be added when multiple spaces are entered in the x-editable textarea
         $value = trim(str_replace(" ", ' ', $value));
         $value = $value !== '' ? $value : null;
         $translation->value = $value;
         $translation->status = $translation->isDirty() && $value != $translation->saved_value ? Translation::STATUS_CHANGED : Translation::STATUS_SAVED;
         $translation->save();
     }
     return array('status' => 'ok');
 }