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

Ranx99's avatar

Posts approvals?

I am trying to implement this scenario:

Posts can have publish and draft as a status

Author dashboard:

  1. User creates a post.
  2. Show disapproved comment for old approval request if any ( related to step 3 in Admin dashboard).
  3. User asks for an approval request for his post.

Admin dashboard:

  1. User can see all approval requests that needs to be reviewed
  2. User can ( approve - disapprove )
  3. If he disapprove he can give a comment on why it was disapproved.
  4. If he approves the post will be published.

While trying to implement this, someone directed me use to the following database structure:

Schema::create('approvals', function (Blueprint $table) {
    $table->id();
    $table->morphs('approvable');
    $table->tinyInteger('status'); // approved - disapproved - under-review
    $table->text('comment')->nullable();
    $table->timestamps();
});
Schema::create('courses', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('user_id');
    $table->string('title');
    $table->text('body');
    $table->tinyInteger('status'); // published - draft
    $table->timestamps();

    $table->foreign('user_id')->references('id')->on('users');
});
  • Do I really need the status field in courses table? isn't the status in approvals is enough?
  • Is there any package out there that I can take inspiration from to implement this?
0 likes
2 replies
Snapey's avatar

unless you have lots of things (other models) that need approving then a polymorphic relationship to an approval model seems a total overkill.

I would have approvals table and model and just store the post_id on the approval.

In the Post model, the post can have many approvals, and all you are interested in is the last one when ordered by date.

Ranx99's avatar

@snapey

So, I will focus only at the latest approval request for a post, then when admin approves the approval, the status of the post will be updated to published?

Please or to participate in this conversation.