Relationships are using queries beneath. They can be intercepted and modified before the database is hit with the query. The following example needs the Author model (or the model associated with the author relationship) to include the QueryCacheable trait.
As the last example, using load() or loadMissing() also works:
$book =Book::findOrFail($bookId);$book->load(['buyers'=>function ($query) {return $query->cacheTags(["book:{$bookId}:buyers"]); },]);foreach ($book->buyers as $buyer) {//}
Relationship Classes
Although you can alter the query during with() and load(), you can also use the Relation classes (like BelongsTo or HasMany) and call Query Cache methods: