To keep it simple, this is same as a status field i.e. active, banned, pending.
Having appropriate where condition will fulfill your requirements.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello there
I'm trying to come up with the best structure for database table which the business requires approval for each update/delete action.
so when new data is entered by system user it doesn't show in the system unless approved by this user's moderator also any update/delete.
here's what I think
ideas table:
#id
#title
#desc
#status_id
#created_by
#updated_by
#action_type ===> create-update-delete
#action_date
#action_info => JSON field to store updates temporarily
#timestamps
so when moderator rejects the action I just clear out actions fields otherwise I update table according to action_info field. if action is delete I just delete the record.
But I think there is a BETTER way to do it don't you think?
@uniqueginun To be flexible, you can have a single table (called “pending updates” or something) that has a polymorphic relation pointing to the model being updated, and then the changed serialised in a JSON column or something. You can then create a controller and view that just paginates through the rows in the table for an admin to approve. If a change is approved, it’s applied to the target model:
class PendingUpdate extends Model
{
protected $casts = [
'changes' => 'json',
];
public function target()
{
// Polymorphic relationship pointing to model being updated
return $this->morphTo();
}
public function approve()
{
// Update model with requested changes
$this->target->update($this->changes);
// Delete this pending update instance
$this->delete();
}
public function reject()
{
// Just simply delete the model if the change is rejected
$this->delete();
}
}
You can then have a controller that calls these model methods to approve/reject a proposed update:
$pendingUpdate->approve();
Please or to participate in this conversation.