announced_at !== null || ! $posting->isOpen()) { return; } $posting->forceFill(['announced_at' => now()])->save(); $notification = new PortalNotification( 'Neue interne Stelle: '.$posting->title, collect([$posting->department, $posting->location, $posting->summary()])->filter()->implode(' · '), route('jobs.show', $posting, false), 'briefcase', ); // Nicht an Rollen, die vom Modul „Stellen“ ausgeschlossen sind $excluded = app(PluginAccess::class)->excludedRoles('stellen'); User::query()->active()->whereKeyNot($posting->created_by ?? 0) ->when($excluded !== [], fn ($q) => $q->whereDoesntHave('roles', fn ($r) => $r->whereIn('roles.id', $excluded))) ->chunkById(500, fn ($users) => Notification::send($users, $notification)); } public function announceDue(): int { $due = JobPosting::query()->open()->whereNull('announced_at')->get(); $due->each(fn (JobPosting $posting) => $this->announceIfDue($posting)); return $due->count(); } }