1.3: fix N+1 in getTranslation by using eager-loaded collection
All checks were successful
Deploy Backend / deploy (push) Successful in 5m43s
All checks were successful
Deploy Backend / deploy (push) Successful in 5m43s
This commit is contained in:
parent
299a98d506
commit
75af8220a7
@ -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