eloquent-versioned icon indicating copy to clipboard operation
eloquent-versioned copied to clipboard

How to check if there are older versions?

Open arrabal opened this issue 8 years ago • 1 comments

Hi, I'd like to thank the contributors for this amazing project. It literally has saved me from creating a DB versioning system from scratch, so I'm really grateful.

After checking the readme, I have a question. I'd like to have something in the result of a query that indicates if there are more than one version of such row. I know there is a field named 'is_current_version' but such field is not retrieved when querying the eloquent model.

For instance, if I had the model Laptop(id, vendor, model) and I invoke Laptop::all(), I'll get a collection of objects with the attributes id, vendor, and model, but nothing else. What's the proper way of retrieving 'is_current_version' as part or the returned fields?

Thanks you.

------ Edit: ----- I just checked and version field is returned in Eloquent queries. Checking if version is >1 is enough, so feel free to close this question and accept my apologies.

arrabal avatar Jun 28 '16 14:06 arrabal

Yeah, all the columns from the DB should be returned and you should be able to do something like

$laptop->is_current_version;
$hasMultipleVersions = $laptop->version > 1;

EspadaV8 avatar Jun 29 '16 00:06 EspadaV8