Пример #1
0
 /**
  * {@inheritdoc}
  */
 public static function loadGroups($userId)
 {
     $table = new Group();
     $select = $table->select()->setIntegrityCheck(false)->from(['gr' => 'group'])->join(['ug' => 'user_to_group'], 'gr.id = ug.group_id', [])->where('ug.user_id = ?', $userId);
     return $table->fetchAll($select);
 }
Пример #2
0
 /**
  * Translate this object to another locale
  * @return mixed
  */
 public function translate($newLocale)
 {
     $clone = Table::locateWithinLocale($this->id, $newLocale);
     if (!$clone) {
         $clone = Table::create();
         $clone->_data = $this->toArray();
         $clone->locale_id = $newLocale;
         $clone->created_by = Table::getAuthUser()->id;
         $clone->save();
     }
     return $clone;
 }