Duplicate queries

Hello,

How can I get rid of duplicate queries? For example I have this query:

             ->relationship('product', 'description', function (Builder $query, Get $get) {
                    $query->where('brand_id', '=', $get('../../brand_id'));
                })

In reality each record has the same brand_id and this query should be executed once. However I have the feeling it gets called on each rows. Is there a way to have this only executed once?
Was this page helpful?