In the revisionable package it's possible to get the identifiable name of a related model by defining the identifiableName()
method on a model, setting the field to display instead of id. E.g. 'name' or 'title'.
Is it possible to do similar with unrelated model. So say I got all revisions for a certain model. E.g.
$revisions = Venturecraft\Revisionable\Revision::where('revisionable_type', 'post')->get();
How can I get the identifiableName
of the post
for which each revision was made?
I can already get the post id with $revision->revisionable_id
but I can't seem to find a way to get the post name without something like Post::find($revision->revisionable_id)->name
which is expensive for a large list of revisions.