From 9c457bffde20b717c7e178b6165791ac6ab89a04 Mon Sep 17 00:00:00 2001 From: tuxarmy Date: Mon, 6 Apr 2026 00:27:32 +0700 Subject: [PATCH] fix: PostObserver trigger published, submit cek kreator, toAll filter aktif, dead code --- app/Filament/Resources/Activities/Tables/ActivitiesTable.php | 3 ++- app/Observers/CashRecordObserver.php | 2 +- app/Observers/PostObserver.php | 2 +- app/Services/NotificationService.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Filament/Resources/Activities/Tables/ActivitiesTable.php b/app/Filament/Resources/Activities/Tables/ActivitiesTable.php index 3c07020..a63269a 100644 --- a/app/Filament/Resources/Activities/Tables/ActivitiesTable.php +++ b/app/Filament/Resources/Activities/Tables/ActivitiesTable.php @@ -52,7 +52,8 @@ class ActivitiesTable ->icon('heroicon-o-paper-airplane') ->color('info') ->requiresConfirmation() - ->visible(fn ($record) => $record->status === 'draft') + ->visible(fn ($record) => $record->status === 'draft' + && $record->created_by === auth()->id()) ->action(fn ($record) => $record->update(['status' => 'pending'])), Action::make('approve') ->label('Setujui') diff --git a/app/Observers/CashRecordObserver.php b/app/Observers/CashRecordObserver.php index 09427ac..043f515 100644 --- a/app/Observers/CashRecordObserver.php +++ b/app/Observers/CashRecordObserver.php @@ -23,7 +23,7 @@ class CashRecordObserver // Threshold: 500rb–2jt → buat approval ketua + notif if ($record->amount >= 500_000 && $record->amount <= 2_000_000) { - $approval = Approval::create([ + Approval::create([ 'model_type' => CashRecord::class, 'model_id' => $record->id, 'required_approvals' => 1, diff --git a/app/Observers/PostObserver.php b/app/Observers/PostObserver.php index 55d1fe1..eec7375 100644 --- a/app/Observers/PostObserver.php +++ b/app/Observers/PostObserver.php @@ -9,7 +9,7 @@ class PostObserver { public function updated(Post $post): void { - if ($post->wasChanged('status') && $post->status === 'approved') { + if ($post->wasChanged('status') && $post->status === 'published') { MemberPoint::firstOrCreate( [ 'user_id' => $post->author_id, diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 93fc9d0..73ac3bd 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -36,6 +36,6 @@ class NotificationService public static function toAll(string $title, string $body, string $color = 'info', ?string $url = null): void { - self::send(User::all(), $title, $body, $color, $url); + self::send(User::where('status', 'aktif')->get(), $title, $body, $color, $url); } }