language; if (!isset($this->with['translations'])) { $this->with([ 'translation' => function ($query) use ($language, $abridge) { /** @var ActiveQuery $query */ $query->where([$this->languageField => $abridge ? substr($language, 0, 2) : $language]); } ]); } return $this; } /** * Scope for querying by all languages * @return $this */ public function multilingual() { if (isset($this->with['translation'])) { unset($this->with['translation']); } $this->with('translations'); return $this; } }