/**
  * Create and return a new query to identify untranslated records.
  *
  * @param string $locale
  * @return \Illuminate\Database\Query\Builder
  */
 protected function untranslatedQuery($locale)
 {
     $table = $this->model->getTable();
     return $this->database->table("{$table} as {$table}")->select("{$table}.id")->leftJoin("{$table} as e", function (JoinClause $query) use($table, $locale) {
         $query->on('e.namespace', '=', "{$table}.namespace")->on('e.group', '=', "{$table}.group")->on('e.item', '=', "{$table}.item")->where('e.locale', '=', $locale);
     })->where("{$table}.locale", $this->defaultLocale)->whereNull("e.id");
 }
 /**
  *  Validate the given attributes
  *
  *  @param  array    $attributes
  *  @return boolean
  */
 public function validate(array $attributes)
 {
     $table = $this->model->getTable();
     $locale = array_get($attributes, 'locale', '');
     $namespace = array_get($attributes, 'namespace', '');
     $group = array_get($attributes, 'group', '');
     $rules = ['locale' => 'required', 'namespace' => 'required', 'group' => 'required', 'item' => "required|unique:{$table},item,NULL,id,locale,{$locale},namespace,{$namespace},group,{$group}", 'text' => ''];
     $validator = $this->app['validator']->make($attributes, $rules);
     if ($validator->fails()) {
         $this->errors = $validator->errors();
         return false;
     }
     return true;
 }