1.3: fix N+1 in getTranslation by using eager-loaded collection
This commit is contained in:
parent
28c7a317e5
commit
1dc72d8563
@ -25,6 +25,9 @@ public function translations()
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
if ($this->relationLoaded('translations')) {
|
||||
return $this->translations->firstWhere('locale', $locale);
|
||||
}
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,9 @@ public function translations()
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
if ($this->relationLoaded('translations')) {
|
||||
return $this->translations->firstWhere('locale', $locale);
|
||||
}
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,9 @@ public function translations()
|
||||
*/
|
||||
public function getTranslation($locale)
|
||||
{
|
||||
if ($this->relationLoaded('translations')) {
|
||||
return $this->translations->firstWhere('locale', $locale);
|
||||
}
|
||||
return $this->translations()->where('locale', $locale)->first();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user