feat: anggota dapat menulis artikel dengan workflow approval sebelum diterbitkan

This commit is contained in:
2026-04-03 06:48:06 +07:00
parent 5d14b55173
commit a7e10600d4
12 changed files with 339 additions and 10 deletions
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->enum('status', ['draft', 'pending', 'published', 'rejected'])
->default('draft')->after('author_id');
$table->foreignId('reviewed_by')->nullable()->constrained('users')->after('status');
$table->text('rejection_reason')->nullable()->after('reviewed_by');
});
}
public function down(): void
{
Schema::table('posts', function (Blueprint $table) {
$table->dropColumn(['status', 'reviewed_by', 'rejection_reason']);
});
}
};
+2 -1
View File
@@ -36,10 +36,11 @@ class PermissionSeeder extends Seeder
->orWhere('name', 'like', 'View:Division')
->get());
// Anggota: hanya lihat kegiatan & voting
// Anggota: lihat kegiatan & voting + kelola artikel sendiri
$anggota->syncPermissions(Permission::whereIn('name', [
'ViewAny:Activity', 'View:Activity',
'ViewAny:Vote', 'View:Vote',
'ViewAny:MyPost', 'View:MyPost', 'Create:MyPost', 'Update:MyPost', 'Delete:MyPost',
])->get());
// Auditor: read-only semua + akses audit
+1 -1
View File
@@ -36,7 +36,7 @@ class PostSeeder extends Seeder
foreach ($posts as $data) {
Post::firstOrCreate(
['slug' => \Illuminate\Support\Str::slug($data['title'])],
array_merge($data, ['author_id' => $author->id])
array_merge($data, ['author_id' => $author->id, 'status' => 'published'])
);
}
}