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

kenny11's avatar

How would you make a "draft" feature?

Let's say you let users publish articles and implement a feature to create a "draft" before publishing an article.

How would you make a relationship and database structure?

0 likes
3 replies
Cronix's avatar
Cronix
Best Answer
Level 67

I'd just throw a status column on the article table. Then a simple Status model with a hasOne relationship in the Article model. Status table would just have 'draft', 'published', etc.

articles:
id
title
...
status_id

statuses:
id
type (published, draft, archived, etc)
2 likes
kenny11's avatar

Yea. That is what I was thinking. Thanks for the comment. I wanted to see if something different comes up

jekinney's avatar

I sometimes set a draft Boolean and/or if you have a published at date can set to null.

2 likes

Please or to participate in this conversation.