Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

James_Moore's avatar

Document revisions relationship

I have a database model Document, a document can have past revisions of itself. The data looks like

  • id
  • name
  • parent_document_id

When a new revision is uploaded the old documents parent_document_id gets set to the new documents id.

I need a way to get all past revisions of a document. Preferably I'd like to use the query builder (or something) so that I can group the revisions by date.

Example

Tuesday, December 15, 2020

  • 12:00 pm | revision-4.xlsx | Created By User: Foo
  • 11:00 am | revision-3.xlsx | Created By User: Jim

Monday, December 14, 2020

  • 12:00 pm | revision-4.xlsx | Created By User: Foo
  • 11:00 am | revision-3.xlsx | Created By User: Jim
0 likes
0 replies

Please or to participate in this conversation.