Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TarikAli's avatar

laravel api Resource extra query

i have table category and table category_info which has translation of category.

and in category model i have a relation :

translation_category_info which get the translation with current locale .

i loaded the relationship category.translation_category_info .

in api resource i want to display the title of translation_category_info like this :

'title' => $this->translation_category_info->isNotEmpty() ? $this->translation_category_info->first()->title : '',

is this line will make another query to get the title or get the title from the data already loaded Thanks

0 likes
0 replies

Please or to participate in this conversation.