jeudi 29 octobre 2015

Caching Lazy Eager Loading Queries in Laravel 5.1

How do I cache the lazy eager loading queries based on the model relationships. For example -

$books = App\Book::all();

$books->load('author', 'publisher');

I can cache the first query with something like this

$books = Cache::remember('allbooks', 60, function() {
             return App\Book::all();
         });

How do I cache the second query?

If there is no direct way, please suggest any workaround, possibly with a sample code.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire