Support the ongoing development of Laravel.io →
Database Eloquent Architecture

I have a CMS/app setup where an admin can make changes, but the changes are only temporary/drafts until the admin press a publish button.

The current database has users, groups, nodes and files + two intermediate tables: group_node and group_user. Nodes can ether be a folder or a file (linked to the files table). The group_node intermediate table decides the which nodes an user can access.

I have a perfect system running. But a very requested feature is to be able to make temporary changes and when done press a publish button.

I can't wrap my head around a solution which does not require a lot of custom work on Eloquent models or a database design which is not too complex. I need the node primary key not to change, when changes are published. I found this post, but can't see a good way to implement it in Eloquent.

Do you have any thoughts? I'm very keen to find a solution, so please tell me if my question is to vague or you need extra information.

Last updated 3 years ago.
0

the SO article suggests you have 2 tables and create a relationship between (lookup Eloqunt Relationships in the docs)

I think it's better, like somebody suggests on SO, to keep everything in one table. The flow will be like

  • user creates new article, type = draft

  • admin presses publish, type changed to published

  • user edits existing article with type published and when the user presses save a new article is created with type = draft and parent_id to the id of the original article

  • admin presses publish, the original article is updated with the data from the draft and the draft is discarded

something like that

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

tougher tougher Joined 27 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.