Posts approvals? I am trying to implement this scenario:
Posts can have publish and draft as a status
Author dashboard:
User creates a post.
Show disapproved comment for old approval request if any ( related to step 3 in Admin dashboard).
User asks for an approval request for his post.
Admin dashboard:
User can see all approval requests that needs to be reviewed
User can ( approve - disapprove )
If he disapprove he can give a comment on why it was disapproved.
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?
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.
@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 sign in or create an account to participate in this conversation.