Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Release 4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Feb 7, 2017
1 parent fb18f27 commit f50e3f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 4.2.1 (released 2017-02-07)

- Fix with translations query

## 4.2.0 (released 2017-02-07)

- Added eager loading support
Expand Down
10 changes: 5 additions & 5 deletions src/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ public function translate(string $locale = null, bool $fallback = true): Model
/**
* Query scope for eager-loading the translations for current (or a given) locale.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string|null $locale
*
* @return void
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function scopeWithTranslations(Builder $builder, string $locale = null)
public function scopeWithTranslations(Builder $query, string $locale = null): Builder
{
$locale = $locale ?: (new static())->getLocale();
$locale = $locale ?: $this->getLocale();

$builder->with(['translations' => function (HasMany $query) use ($locale) {
return $query->with(['translations' => function (HasMany $query) use ($locale) {
$query->where('locale', $locale);
}]);
}
Expand Down

0 comments on commit f50e3f4

Please sign in to comment.