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

Commit

Permalink
Reorder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Feb 7, 2017
1 parent 001c6a0 commit fb18f27
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ trait Translatable
*/
protected $cache = [];

/**
* Query scope for eager-loading the translations for current (or a given) locale.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param string|null $locale
*
* @return void
*/
public static function scopeWithTranslations(Builder $builder, string $locale = null)
{
$locale = $locale ?: (new static())->getLocale();

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

/**
* Get a translation.
*
Expand All @@ -75,6 +58,23 @@ public function translate(string $locale = null, bool $fallback = true): Model
return $translation;
}

/**
* Query scope for eager-loading the translations for current (or a given) locale.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param string|null $locale
*
* @return void
*/
public static function scopeWithTranslations(Builder $builder, string $locale = null)
{
$locale = $locale ?: (new static())->getLocale();

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

/**
* Get a translation or create new.
*
Expand Down

0 comments on commit fb18f27

Please sign in to comment.