app->make(Navigation::class)->add('stellen', 'Stellen', '/stellen', active: 'jobs.*', sort: 72, icon: 'briefcase'); $this->app->make(Digest::class)->add('stellen', 'Neue interne Stellen', 50, fn (User $user, CarbonImmutable $since) => JobPosting::query() ->open()->where('published_at', '>=', $since)->latest('published_at')->limit(5)->get() ->map(fn (JobPosting $posting) => [ 'title' => $posting->title, 'url' => route('jobs.show', $posting), 'meta' => collect([$posting->department, $posting->location, $posting->deadline ? 'Frist '.$posting->deadline->format('d.m.') : null])->filter()->implode(' · '), ])->all()); $abilities = $this->app->make(Abilities::class); $abilities->define('jobs.manage', 'Stellen ausschreiben und bearbeiten', 'Stellen', portal: true); $abilities->define('jobs.applications', 'Bewerbungen aller Stellen einsehen und bearbeiten', 'Stellen', portal: true); // Mediathek „Eingebunden in“: Bilder in der Beschreibung $usages = $this->app->make(MediaUsages::class); $usages->add('stellen', 'Stellen', fn (JobPosting $p) => [ ['context' => ImagePaths::HTML_CONTEXT, 'label' => $p->title, 'url' => route('jobs.edit', $p, false), 'draft' => $p->published_at === null, 'paths' => ImagePaths::fromHtml($p->description)], ], fn (callable $each) => JobPosting::query()->chunkById(100, fn ($postings) => $postings->each($each))); $usages->watch('stellen', JobPosting::class, ['description', 'title', 'published_at']); $this->app->make(GlobalSearch::class)->add('stellen', 'Stellen', 'briefcase', fn (...$args) => app(JobSearch::class)(...$args), sort: 55); $this->app->make(Editorial::class)->add('stellen', 'Stellen', 'stellen::EditorialJobs', 35, fn (User $user) => $user->can('jobs.manage') || $user->can('jobs.applications'), fn (User $user) => [ 'postings' => JobPosting::query()->withCount('applications')->orderByRaw('published_at IS NULL DESC')->orderByDesc('published_at')->limit(50)->get() ->map(fn (JobPosting $p) => [...Presenter::card($p), 'applications' => $p->applications_count, 'edit_url' => route('jobs.edit', $p), 'applications_url' => route('jobs.applications', $p)])->all(), 'canCreate' => $user->can('jobs.manage'), ]); $this->app->make(Editorial::class)->meta('stellen', icon: 'briefcase', todo: function (User $user) { $count = $user->can('jobs.applications') || $user->can('jobs.manage') ? JobApplication::query()->where('status', 'received')->whereNull('withdrawn_at')->count() : 0; return ['count' => $count, 'label' => $count === 1 ? 'neue Bewerbung' : 'neue Bewerbungen']; }, create: fn (User $user) => $user->can('jobs.manage') ? ['label' => 'Stelle ausschreiben', 'href' => route('jobs.create')] : null); } public function boot(): void { // Geplante Stellen ankündigen, sobald sie erscheinen Schedule::call(fn () => $this->app->make(Announcer::class)->announceDue())->everyTenMinutes()->name('stellen-announce')->withoutOverlapping(10); } }