From b1cd5492c158c4231c65c6b9652dee2fcef43f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Wed, 5 Nov 2025 10:14:37 -0300 Subject: [PATCH] Add draft functionality for page management: Implemented a new bulk action to move selected pages to draft status in the PagesTable. Added corresponding localization keys for English and Turkish languages to enhance user experience. --- .../Resources/Pages/Tables/PagesTable.php | 20 +++++++++++++++++++ app/Models/Page.php | 9 +++++++++ lang/en/pages.php | 2 ++ lang/tr/pages.php | 2 ++ 4 files changed, 33 insertions(+) diff --git a/app/Filament/Admin/Resources/Pages/Tables/PagesTable.php b/app/Filament/Admin/Resources/Pages/Tables/PagesTable.php index 0a8e91e..be6c52c 100644 --- a/app/Filament/Admin/Resources/Pages/Tables/PagesTable.php +++ b/app/Filament/Admin/Resources/Pages/Tables/PagesTable.php @@ -161,6 +161,26 @@ class PagesTable ->requiresConfirmation() ->deselectRecordsAfterCompletion(), + BulkAction::make('draft') + ->label(__('pages.bulk_action_draft')) + ->icon('heroicon-o-document-text') + ->color('warning') + ->action(function ($records) { + $count = 0; + foreach ($records as $record) { + if ($record->draft()) { + $count++; + } + } + + Notification::make() + ->title(__('pages.bulk_drafted_successfully', ['count' => $count])) + ->success() + ->send(); + }) + ->requiresConfirmation() + ->deselectRecordsAfterCompletion(), + DeleteBulkAction::make(), ForceDeleteBulkAction::make(), RestoreBulkAction::make(), diff --git a/app/Models/Page.php b/app/Models/Page.php index 6f7365a..983657f 100644 --- a/app/Models/Page.php +++ b/app/Models/Page.php @@ -244,4 +244,13 @@ class Page extends Model } return $this->save(); } + + /** + * Set the page to draft status + */ + public function draft(): bool + { + $this->status = 'draft'; + return $this->save(); + } } diff --git a/lang/en/pages.php b/lang/en/pages.php index 39e4382..2067810 100644 --- a/lang/en/pages.php +++ b/lang/en/pages.php @@ -174,6 +174,8 @@ return [ // Bulk Actions 'bulk_action_duplicate' => 'Duplicate Selected', 'bulk_action_publish' => 'Publish Selected', + 'bulk_action_draft' => 'Move to Draft', 'bulk_duplicated_successfully' => ':count page(s) duplicated successfully.', 'bulk_published_successfully' => ':count page(s) published successfully.', + 'bulk_drafted_successfully' => ':count page(s) moved to draft successfully.', ]; diff --git a/lang/tr/pages.php b/lang/tr/pages.php index f0df88e..7394452 100644 --- a/lang/tr/pages.php +++ b/lang/tr/pages.php @@ -174,6 +174,8 @@ return [ // Bulk Actions 'bulk_action_duplicate' => 'Seçilenleri Çoğalt', 'bulk_action_publish' => 'Seçilenleri Yayınla', + 'bulk_action_draft' => 'Seçilenleri Taslağa Al', 'bulk_duplicated_successfully' => ':count sayfa başarıyla çoğaltıldı.', 'bulk_published_successfully' => ':count sayfa başarıyla yayınlandı.', + 'bulk_drafted_successfully' => ':count sayfa başarıyla taslağa alındı.', ];