Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #148 from Pyton/master
Browse files Browse the repository at this point in the history
Add retriving default locale for translatedIn method
  • Loading branch information
dimsav committed Oct 17, 2015
2 parents 4edfd1f + d832771 commit 8c075ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Translatable/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,16 @@ public function __isset($key)
}

/**
* Return only if has translation
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $locale
*
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function scopeTranslatedIn(Builder $query, $locale)
public function scopeTranslatedIn(Builder $query, $locale = null)
{
$locale = $locale ?: app()->getLocale();

return $query->whereHas('translations', function (Builder $q) use ($locale) {
$q->where($this->getLocaleKey(), '=', $locale);
});
Expand Down

0 comments on commit 8c075ae

Please sign in to comment.