feat: anggota dapat menulis artikel dengan workflow approval sebelum diterbitkan
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Posts\Tables;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
@@ -22,18 +24,52 @@ class PostsTable
|
||||
'berita' => 'info',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextColumn::make('status')->badge()
|
||||
->color(fn ($state) => match ($state) {
|
||||
'published' => 'success',
|
||||
'pending' => 'warning',
|
||||
'rejected' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextColumn::make('author.name')->label('Penulis'),
|
||||
TextColumn::make('published_at')->label('Dipublikasi')
|
||||
->dateTime('d M Y')->default('Draft')->sortable(),
|
||||
->dateTime('d M Y')->default('-')->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('category')->options([
|
||||
'umum' => 'Umum',
|
||||
'pengumuman' => 'Pengumuman',
|
||||
'berita' => 'Berita',
|
||||
SelectFilter::make('status')->options([
|
||||
'draft' => 'Draft',
|
||||
'pending' => 'Menunggu',
|
||||
'published' => 'Diterbitkan',
|
||||
'rejected' => 'Ditolak',
|
||||
]),
|
||||
])
|
||||
->recordActions([EditAction::make()])
|
||||
->recordActions([
|
||||
Action::make('publish')
|
||||
->label('Terbitkan')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->color('success')
|
||||
->requiresConfirmation()
|
||||
->visible(fn ($record) => $record->status === 'pending')
|
||||
->action(fn ($record) => $record->update([
|
||||
'status' => 'published',
|
||||
'published_at' => now(),
|
||||
'reviewed_by' => auth()->id(),
|
||||
])),
|
||||
Action::make('reject')
|
||||
->label('Tolak')
|
||||
->icon('heroicon-o-x-circle')
|
||||
->color('danger')
|
||||
->visible(fn ($record) => $record->status === 'pending')
|
||||
->form([
|
||||
Textarea::make('rejection_reason')->label('Alasan Penolakan')->required(),
|
||||
])
|
||||
->action(fn ($record, array $data) => $record->update([
|
||||
'status' => 'rejected',
|
||||
'reviewed_by' => auth()->id(),
|
||||
'rejection_reason' => $data['rejection_reason'],
|
||||
])),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([BulkActionGroup::make([DeleteBulkAction::make()])]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user