Ranx99
5 months ago
743
2
Tips

Posts approvals?

Posted 5 months ago by Ranx99

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?

Please sign in or create an account to participate in this conversation.