Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m51s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m48s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m16s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 9m30s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m44s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 8m49s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m37s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m8s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
67 lines
3.7 KiB
PHP
67 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace Inhaus\Plugins\Stellen;
|
|
|
|
use App\Digest\Digest;
|
|
use App\Editorial\Editorial;
|
|
use App\Media\ImagePaths;
|
|
use App\Media\MediaUsages;
|
|
use App\Models\User;
|
|
use App\Plugins\Plugin;
|
|
use App\Search\GlobalSearch;
|
|
use App\Support\Abilities;
|
|
use App\Support\Navigation;
|
|
use Carbon\CarbonImmutable;
|
|
use Illuminate\Support\Facades\Schedule;
|
|
use Inhaus\Plugins\Stellen\Models\JobApplication;
|
|
use Inhaus\Plugins\Stellen\Models\JobPosting;
|
|
|
|
class StellenPlugin extends Plugin
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->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);
|
|
}
|
|
}
|