*/ public function via(object $notifiable): array { return ['database']; } /** * @return array */ public function toDatabase(object $notifiable): array { return FilamentNotification::make() ->title(__('panel.reviews.notification.title', [ 'name' => $this->requestedBy ?? __('panel.revisions.system'), ])) ->body(trim(ContentTypes::title($this->record).($this->note ? " — {$this->note}" : ''))) ->icon('heroicon-o-hand-raised') ->iconColor('warning') ->actions([ Action::make('review') ->label(__('panel.reviews.actions.open')) ->url(ReviewTarget::url($this->record)) ->markAsRead(), ]) ->getDatabaseMessage(); } /** * Who is told. * * A named reviewer, when there is one. Otherwise everybody who could * actually act on it — resolved through `can()` rather than a permission * scope so super admins are included, since they hold no explicit * permissions at all, only the gate that grants them everything. * * The person who asked is never told about their own request. * * @return Collection */ public static function recipients(Model $record): Collection { if ($record->reviewer_id !== null) { return User::query() ->whereKey($record->reviewer_id) ->where('is_active', true) ->get(); } $permission = ReviewTarget::permission($record); return User::query() ->where('is_active', true) ->whereKeyNot($record->review_requested_by) ->get() ->filter(fn (User $user) => $user->can($permission)) ->values(); } }