Support the ongoing development of Laravel.io →
Cache Database Eloquent
Last updated 2 years ago.
0

Use remember either on the relationship definition:

public function someRelation()
{
  return $this->hasMany('Model')->remember(2);
}

or the relation loading itself:

Model::with([
  'first' => function ($q) {$q->remember(2);}
  'second' => ...
])
->orderBy('title')
->remember(2,'domain.query')
->get()
Last updated 2 years ago.
0

jarektkaczyk said:

Use remember either on the relationship definition:

public function someRelation()
{
 return $this->hasMany('Model')->remember(2);
}

or the relation loading itself:

Model::with([
 'first' => function ($q) {$q->remember(2);}
 'second' => ...
])
->orderBy('title')
->remember(2,'domain.query')
->get()

Thank you for your solution :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.