Neues Modul Interne Stellenausschreibungen (0.28.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m1s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m8s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m42s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m37s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m43s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 10:16:48 +00:00
parent b322b97f32
commit 993d49c99c
146 changed files with 1981 additions and 305 deletions

View file

@ -0,0 +1,60 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('job_postings', function (Blueprint $table) {
$table->id();
$table->string('title', 200);
$table->string('department', 150)->nullable(); // Bereich
$table->string('location', 150)->nullable(); // Standort
$table->string('employment', 20)->default('full'); // full | part | mini | training | other
$table->string('hours', 60)->nullable(); // z. B. „30 Std./Woche“
$table->string('contract', 20)->default('permanent'); // permanent | fixed
$table->string('contract_note', 120)->nullable(); // z. B. „bis 31.12.2027“
$table->string('pay_grade', 60)->nullable(); // Eingruppierung
$table->string('start', 60)->nullable(); // „ab sofort“, „01.01.2027“
$table->date('deadline')->nullable(); // Bewerbungsfrist
$table->longText('description')->nullable(); // bereinigtes HTML
$table->string('pdf_path')->nullable();
$table->string('pdf_name')->nullable();
$table->string('apply_mode', 10)->default('online'); // online | contact | link
$table->string('apply_url', 1000)->nullable();
$table->foreignId('contact_id')->nullable()->constrained('users')->nullOnDelete();
$table->string('notify_email', 190)->nullable(); // Bewerbungen zusätzlich per E-Mail
$table->timestamp('published_at')->nullable(); // null = Entwurf
$table->timestamp('announced_at')->nullable(); // Benachrichtigung verschickt
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index(['published_at', 'deadline']);
});
Schema::create('job_applications', function (Blueprint $table) {
$table->id();
$table->foreignId('posting_id')->constrained('job_postings')->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->text('message')->nullable();
$table->string('file_path')->nullable();
$table->string('file_name')->nullable();
$table->string('status', 20)->default('received'); // received | review | interview | closed
$table->text('note')->nullable(); // interne Notiz der Personalabteilung
$table->timestamp('withdrawn_at')->nullable();
$table->timestamps();
$table->unique(['posting_id', 'user_id']);
});
}
public function down(): void
{
Schema::dropIfExists('job_applications');
Schema::dropIfExists('job_postings');
}
};

View file

@ -0,0 +1,14 @@
{
"slug": "stellen",
"name": "Interne Stellenausschreibungen",
"version": "1.0.0",
"description": "Offene Stellen für Mitarbeitende – mit Bereich, Standort, Umfang, Frist, Beschreibung und PDF. Bewerbung online im Portal oder über Ansprechperson bzw. Link, Benachrichtigung bei neuen Stellen.",
"author": "Inhaus",
"namespace": "Inhaus\\Plugins\\Stellen\\",
"class": "Inhaus\\Plugins\\Stellen\\StellenPlugin",
"enabled_by_default": false,
"requires": {
"core": ">=0.27.0",
"php": ">=8.3"
}
}

View file

@ -0,0 +1,16 @@
<script setup>
import { Building2, CalendarClock, Clock, MapPin } from '@lucide/vue';
import { formatShortDate } from '@/lib/format';
/** Eckdaten einer Stelle als kleine Zeile mit Symbolen */
defineProps({ posting: { type: Object, required: true } });
</script>
<template>
<p class="flex flex-wrap items-center gap-x-4 gap-y-1 text-[13px] text-muted-foreground">
<span v-if="posting.department" class="inline-flex items-center gap-1.5"><Building2 class="size-3.5" /> {{ posting.department }}</span>
<span v-if="posting.location" class="inline-flex items-center gap-1.5"><MapPin class="size-3.5" /> {{ posting.location }}</span>
<span v-if="posting.summary" class="inline-flex items-center gap-1.5"><Clock class="size-3.5" /> {{ posting.summary }}</span>
<span v-if="posting.deadline" class="inline-flex items-center gap-1.5"><CalendarClock class="size-3.5" /> Bewerbung bis {{ formatShortDate(posting.deadline) }}</span>
</p>
</template>

View file

@ -0,0 +1,38 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Plus, Users } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import Panel from '@/components/Panel.vue';
import { formatShortDate } from '@/lib/format';
defineProps({
postings: { type: Array, required: true },
canCreate: { type: Boolean, default: false },
});
const statuses = {
open: ['Offen', 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200'],
draft: ['Entwurf', 'bg-muted text-muted-foreground'],
scheduled: ['Geplant', 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200'],
expired: ['Frist abgelaufen', 'bg-muted text-muted-foreground'],
};
</script>
<template>
<Panel title="Stellen">
<template #actions>
<Button v-if="canCreate" size="sm" variant="outline" as-child><Link href="/redaktion/stellen/neu"><Plus /> Stelle ausschreiben</Link></Button>
</template>
<ul v-if="postings.length" class="-mx-5 divide-y border-t">
<li v-for="posting in postings" :key="posting.id" class="flex items-center gap-3 px-5 py-2.5">
<div class="min-w-0 flex-1">
<Link :href="canCreate ? posting.edit_url : posting.url" class="block truncate text-sm font-medium hover:underline">{{ posting.title }}</Link>
<p class="truncate text-xs text-muted-foreground">{{ [posting.department, posting.location, posting.deadline ? `Frist ${formatShortDate(posting.deadline)}` : null].filter(Boolean).join(' · ') }}</p>
</div>
<Link :href="posting.applications_url" class="inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground hover:text-foreground" :title="`${posting.applications} Bewerbungen`"><Users class="size-3.5" /> {{ posting.applications }}</Link>
<span class="shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium" :class="statuses[posting.status][1]">{{ statuses[posting.status][0] }}</span>
</li>
</ul>
<p v-else class="text-sm text-muted-foreground">Noch keine Stellen ausgeschrieben.</p>
</Panel>
</template>

View file

@ -0,0 +1,61 @@
<script setup>
import { reactive, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Download, Mail, Users } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
/**
* Bewerbungen auf eine Stelle – vertraulich (Ansprechperson und „Bewerbungen einsehen“).
*/
const props = defineProps({
posting: { type: Object, required: true },
applications: { type: Array, required: true },
statuses: { type: Array, required: true },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status));
const edits = reactive(Object.fromEntries(props.applications.map((a) => [a.id, { status: a.status, note: a.note ?? '' }])));
function save(application) {
router.put(`/redaktion/stellen/bewerbungen/${application.id}`, edits[application.id], { preserveScroll: true });
}
</script>
<template>
<AppLayout :title="`Bewerbungen: ${posting.title}`">
<PageHeader :title="`Bewerbungen (${applications.length})`" :description="posting.title" :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }, { label: posting.title, href: posting.url }]" />
<ul v-if="applications.length" class="grid gap-4">
<li v-for="application in applications" :key="application.id" class="rounded-lg border bg-card p-5">
<div class="flex flex-wrap items-start gap-4">
<PersonAvatar :person="application.person" class="size-11" />
<div class="min-w-0 flex-1">
<Link :href="`/personen/${application.person.id}`" class="font-semibold hover:underline">{{ application.person.name }}</Link>
<p class="text-[13px] text-muted-foreground">{{ [application.person.job_title, application.person.department].filter(Boolean).join(' · ') || '–' }}</p>
<p class="text-xs text-muted-foreground">Eingegangen am {{ formatShortDate(application.created_at) }}</p>
</div>
<div class="flex flex-wrap gap-2">
<Button v-if="application.file" variant="outline" size="sm" as-child><a :href="application.file.url"><Download /> {{ application.file.name }}</a></Button>
<Button variant="outline" size="sm" as-child><a :href="`mailto:${application.person.email}`"><Mail /> E-Mail</a></Button>
</div>
</div>
<p v-if="application.message" class="mt-4 rounded-md bg-muted/60 px-4 py-3 text-sm leading-relaxed break-words whitespace-pre-line">{{ application.message }}</p>
<form class="mt-4 grid gap-3 border-t pt-4 sm:grid-cols-[12rem_minmax(0,1fr)_auto] sm:items-end" @submit.prevent="save(application)">
<label class="grid gap-1 text-[13px] font-medium">Stand <NativeSelect v-model="edits[application.id].status" :options="statuses" /></label>
<label class="grid gap-1 text-[13px] font-medium">Interne Notiz <input v-model="edits[application.id].note" maxlength="5000" placeholder="nur für die Bearbeitung sichtbar" class="h-9 rounded-md border border-input bg-card px-3 text-sm font-normal focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/30" /></label>
<Button type="submit" size="sm" class="h-9">Speichern</Button>
</form>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card"><EmptyState :icon="Users" title="Noch keine Bewerbungen" /></div>
</AppLayout>
</template>

View file

@ -0,0 +1,163 @@
<script setup>
import { computed, ref } from 'vue';
import { router, useForm } from '@inertiajs/vue3';
import { FileText, LoaderCircle, Save, Trash2, X } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import FormField from '@/components/FormField.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import Panel from '@/components/Panel.vue';
import PersonPicker from '@/components/PersonPicker.vue';
import RichTextEditor from '@/components/RichTextEditor.vue';
import AppLayout from '@/layouts/AppLayout.vue';
/**
* Stelle ausschreiben oder bearbeiten.
*/
const props = defineProps({
posting: { type: Object, default: null },
options: { type: Object, required: true },
});
const p = props.posting;
const form = useForm({
title: p?.title ?? '',
department: p?.department ?? '',
location: p?.location ?? '',
employment: p?.employment ?? 'full',
hours: p?.hours ?? '',
contract: p?.contract ?? 'permanent',
contract_note: p?.contract_note ?? '',
pay_grade: p?.pay_grade ?? '',
start: p?.start ?? '',
deadline: p?.deadline ?? '',
description: p?.description ?? '',
apply_mode: p?.apply_mode ?? 'online',
apply_url: p?.apply_url ?? '',
contact_id: p?.contact?.id ?? null,
notify_email: p?.notify_email ?? '',
publish: !p ? 'now' : p.status === 'draft' ? 'draft' : p.status === 'scheduled' ? 'at' : 'now',
published_at: p?.published_at ?? '',
pdf: null,
remove_pdf: false,
});
const pdfInput = ref(null);
const pdfName = computed(() => form.pdf?.name ?? (form.remove_pdf ? null : p?.pdf_name));
const publishOptions = [
{ value: 'now', label: p?.status === 'open' || p?.status === 'expired' ? 'Veröffentlicht' : 'Sofort veröffentlichen' },
{ value: 'at', label: 'Zu einem Zeitpunkt' },
{ value: 'draft', label: 'Entwurf (nicht sichtbar)' },
];
function submit() {
const options = { forceFormData: true, preserveScroll: true };
p ? form.post(`/redaktion/stellen/${p.id}`, options) : form.post('/redaktion/stellen', options);
}
function remove() {
const warning = p.applications ? ` Auch die ${p.applications} Bewerbung(en) werden gelöscht.` : '';
if (window.confirm(`Stelle „${p.title}“ löschen?${warning}`)) {
router.delete(`/redaktion/stellen/${p.id}`);
}
}
</script>
<template>
<AppLayout :title="p ? `Bearbeiten: ${p.title}` : 'Stelle ausschreiben'">
<PageHeader :title="p ? 'Stelle bearbeiten' : 'Stelle ausschreiben'" :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }]">
<template #actions>
<Button v-if="p" variant="ghost" class="text-destructive hover:text-destructive" @click="remove"><Trash2 /> Löschen</Button>
<Button :disabled="form.processing" @click="submit"><LoaderCircle v-if="form.processing" class="animate-spin" /><Save v-else /> Speichern</Button>
</template>
</PageHeader>
<form class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]" @submit.prevent="submit">
<div class="grid min-w-0 gap-6">
<Panel>
<div class="grid gap-5">
<FormField id="job-title" label="Titel der Stelle" :error="form.errors.title">
<Input id="job-title" v-model="form.title" maxlength="200" placeholder="z. B. Pflegefachkraft (m/w/d) im Nachtdienst" class="text-base" />
</FormField>
<div class="grid gap-4 sm:grid-cols-2">
<FormField id="job-dept" label="Bereich" :error="form.errors.department">
<Input id="job-dept" v-model="form.department" maxlength="150" list="job-departments" placeholder="z. B. Pflege" />
<datalist id="job-departments"><option v-for="d in options.departments" :key="d" :value="d" /></datalist>
</FormField>
<FormField id="job-location" label="Standort" :error="form.errors.location">
<Input id="job-location" v-model="form.location" maxlength="150" list="job-locations" placeholder="z. B. Haus am See" />
<datalist id="job-locations"><option v-for="l in options.locations" :key="l" :value="l" /></datalist>
</FormField>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<FormField id="job-employment" label="Umfang" :error="form.errors.employment">
<NativeSelect id="job-employment" v-model="form.employment" :options="options.employment" />
</FormField>
<FormField id="job-hours" label="Stunden (optional)" :error="form.errors.hours">
<Input id="job-hours" v-model="form.hours" maxlength="60" placeholder="z. B. 30 Std./Woche" />
</FormField>
<FormField id="job-contract" label="Vertrag" :error="form.errors.contract">
<NativeSelect id="job-contract" v-model="form.contract" :options="options.contract" />
</FormField>
<FormField v-if="form.contract === 'fixed'" id="job-contract-note" label="Befristung" :error="form.errors.contract_note">
<Input id="job-contract-note" v-model="form.contract_note" maxlength="120" placeholder="z. B. bis 31.12.2027 (Elternzeitvertretung)" />
</FormField>
<FormField id="job-pay" label="Eingruppierung (optional)" :error="form.errors.pay_grade">
<Input id="job-pay" v-model="form.pay_grade" maxlength="60" placeholder="z. B. AVR P8" />
</FormField>
<FormField id="job-start" label="Beginn (optional)" :error="form.errors.start">
<Input id="job-start" v-model="form.start" maxlength="60" placeholder="z. B. ab sofort" />
</FormField>
</div>
<FormField id="job-description" label="Beschreibung" :error="form.errors.description" hint="Zum Beispiel: Ihre Aufgaben, Ihr Profil, Wir bieten.">
<RichTextEditor v-model="form.description" bordered min-height="16rem" />
</FormField>
<FormField id="job-pdf" label="Ausschreibung als PDF (optional)" :error="form.errors.pdf">
<div class="flex flex-wrap items-center gap-2">
<input ref="pdfInput" type="file" accept=".pdf" class="hidden" @change="(form.pdf = $event.target.files?.[0] ?? null), (form.remove_pdf = false)" />
<Button type="button" variant="outline" size="sm" @click="pdfInput?.click()"><FileText /> {{ pdfName ? 'Andere Datei' : 'PDF auswählen' }}</Button>
<span v-if="pdfName" class="inline-flex min-w-0 items-center gap-1 text-[13px] text-muted-foreground">
<span class="truncate">{{ pdfName }}</span>
<button type="button" class="rounded p-0.5 hover:text-destructive" aria-label="PDF entfernen" @click="(form.pdf = null), (form.remove_pdf = true)"><X class="size-3.5" /></button>
</span>
</div>
</FormField>
</div>
</Panel>
</div>
<div class="grid gap-6">
<Panel title="Veröffentlichung">
<div class="grid gap-4">
<NativeSelect v-model="form.publish" :options="publishOptions" aria-label="Veröffentlichung" />
<FormField v-if="form.publish === 'at'" id="job-publish-at" label="Erscheint am" :error="form.errors.published_at">
<Input id="job-publish-at" v-model="form.published_at" type="datetime-local" />
</FormField>
<FormField id="job-deadline" label="Bewerbungsfrist" :error="form.errors.deadline" hint="Danach verschwindet die Stelle aus der Liste. Leer = ohne Frist.">
<Input id="job-deadline" v-model="form.deadline" type="date" />
</FormField>
<p v-if="!p || p.status !== 'open'" class="text-xs text-muted-foreground">Beim Erscheinen werden alle Mitarbeitenden einmalig benachrichtigt.</p>
</div>
</Panel>
<Panel title="Bewerbung">
<div class="grid gap-4">
<NativeSelect v-model="form.apply_mode" :options="options.apply_modes" aria-label="Art der Bewerbung" />
<FormField v-if="form.apply_mode === 'link'" id="job-apply-url" label="Link zur Bewerbung" :error="form.errors.apply_url">
<Input id="job-apply-url" v-model="form.apply_url" maxlength="1000" placeholder="https://…" />
</FormField>
<FormField id="job-contact" label="Ansprechperson" :error="form.errors.contact_id" :hint="form.apply_mode === 'online' ? 'Erhält die Bewerbungen im Portal. Ohne Ansprechperson: alle mit „Bewerbungen einsehen“.' : 'Wird bei der Stelle mit E-Mail und Telefon gezeigt.'">
<PersonPicker id="job-contact" v-model="form.contact_id" :person="p?.contact" />
</FormField>
<FormField v-if="form.apply_mode === 'online'" id="job-notify" label="Zusätzlich per E-Mail an (optional)" :error="form.errors.notify_email" hint="Nur ein Hinweis mit Link – Unterlagen bleiben im Portal.">
<Input id="job-notify" v-model="form.notify_email" type="email" maxlength="190" placeholder="z. B. personal@firma.de" />
</FormField>
</div>
</Panel>
</div>
</form>
</AppLayout>
</template>

View file

@ -0,0 +1,88 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { Link, usePage } from '@inertiajs/vue3';
import { Briefcase, CircleCheck, FileUser, Plus, Search } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import NativeSelect from '@/components/NativeSelect.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import JobFacts from '../components/JobFacts.vue';
/**
* Interne Stellenausschreibungen: offene Stellen mit Filter nach Bereich, Standort und Umfang.
*/
const props = defineProps({
postings: { type: Array, required: true },
filters: { type: Object, required: true },
canManage: { type: Boolean, default: false },
myApplications: { type: Number, default: 0 },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
const query = ref('');
const department = ref(null);
const location = ref(null);
const employment = ref(null);
const normalize = (text) => String(text ?? '').toLocaleLowerCase('de-DE').normalize('NFD').replace(/[̀-ͯ]/g, '');
const list = computed(() => props.postings.filter((p) =>
(!department.value || p.department === department.value)
&& (!location.value || p.location === location.value)
&& (!employment.value || p.employment === employment.value)
&& (!query.value.trim() || normalize(`${p.title} ${p.department ?? ''} ${p.location ?? ''}`).includes(normalize(query.value.trim())))));
const filtered = computed(() => query.value || department.value || location.value || employment.value);
const isNew = (posting) => Date.now() - new Date(posting.published_at) < 7 * 86400000;
function reset() {
query.value = '';
department.value = location.value = employment.value = null;
}
</script>
<template>
<AppLayout title="Stellen">
<PageHeader title="Interne Stellen" description="Offene Stellen im Unternehmen – für Ihren nächsten Schritt.">
<template #actions>
<Button v-if="myApplications" variant="outline" class="h-10" as-child><Link href="/stellen/meine-bewerbungen"><FileUser /> Meine Bewerbungen ({{ myApplications }})</Link></Button>
<Button v-if="canManage" class="h-10" as-child><Link href="/redaktion/stellen/neu"><Plus /> Stelle ausschreiben</Link></Button>
</template>
</PageHeader>
<div v-if="postings.length" class="mb-6 grid gap-3 rounded-lg border bg-card p-3 sm:grid-cols-2 lg:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(0,1fr))]">
<div class="relative">
<Search class="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
<input v-model="query" type="search" placeholder="Stelle suchen …" aria-label="Stellen durchsuchen" class="h-9 w-full rounded-md border border-input bg-card pr-3 pl-9 text-sm shadow-xs focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none" />
</div>
<NativeSelect v-model="department" :options="filters.departments.map((d) => ({ value: d, label: d }))" placeholder="Alle Bereiche" aria-label="Bereich" />
<NativeSelect v-model="location" :options="filters.locations.map((l) => ({ value: l, label: l }))" placeholder="Alle Standorte" aria-label="Standort" />
<NativeSelect v-model="employment" :options="filters.employments" placeholder="Jeder Umfang" aria-label="Umfang" />
</div>
<ul v-if="list.length" class="grid gap-3">
<li v-for="posting in list" :key="posting.id">
<Link :href="posting.url" class="group flex items-start gap-4 rounded-lg border bg-card p-4 transition-shadow hover:shadow-md sm:p-5">
<span class="hidden size-11 shrink-0 place-items-center rounded-lg bg-brand-soft text-brand-text sm:grid"><Briefcase class="size-5" /></span>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-center gap-2">
<h2 class="text-base font-semibold break-words group-hover:underline">{{ posting.title }}</h2>
<span v-if="isNew(posting)" class="rounded-pill bg-brand px-2 py-0.5 text-[11px] font-semibold text-brand-foreground">Neu</span>
<span v-if="posting.applied" class="inline-flex items-center gap-1 rounded-pill bg-emerald-100 px-2 py-0.5 text-[11px] font-semibold text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300"><CircleCheck class="size-3" /> Beworben</span>
</div>
<JobFacts :posting="posting" class="mt-1.5" />
</div>
</Link>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card">
<EmptyState :icon="Briefcase" :title="filtered ? 'Keine passende Stelle' : 'Derzeit keine offenen Stellen'" :text="filtered ? 'Mit anderen Filtern gibt es vielleicht Treffer.' : 'Neue Stellen erscheinen hier – Sie werden benachrichtigt.'">
<Button v-if="filtered" variant="outline" class="mt-4" @click="reset">Filter zurücksetzen</Button>
</EmptyState>
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,37 @@
<script setup>
import { Link, router } from '@inertiajs/vue3';
import { FileUser } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
defineProps({ applications: { type: Array, required: true } });
const tone = { received: 'bg-muted text-muted-foreground', review: 'bg-brand-soft text-brand-soft-foreground', interview: 'bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-300', closed: 'bg-muted text-muted-foreground' };
function withdraw(application) {
if (window.confirm('Bewerbung zurückziehen? Nachricht und Unterlagen werden gelöscht.')) {
router.delete(`/stellen/bewerbungen/${application.id}`, { preserveScroll: true });
}
}
</script>
<template>
<AppLayout title="Meine Bewerbungen">
<PageHeader title="Meine Bewerbungen" description="Nur Sie und die zuständigen Personen sehen diese Bewerbungen." :breadcrumbs="[{ label: 'Stellen', href: '/stellen' }]" />
<ul v-if="applications.length" class="divide-y overflow-hidden rounded-lg border bg-card">
<li v-for="application in applications" :key="application.id" class="flex flex-wrap items-center gap-x-4 gap-y-2 px-5 py-4">
<div class="min-w-0 flex-1">
<Link :href="application.posting.url" class="font-medium hover:underline">{{ application.posting.title }}</Link>
<p class="text-xs text-muted-foreground">Beworben am {{ formatShortDate(application.created_at) }}<template v-if="application.file"> · {{ application.file.name }}</template></p>
</div>
<span class="rounded-pill px-2.5 py-0.5 text-xs font-medium" :class="tone[application.status]">{{ application.status_label }}</span>
<Button v-if="application.status === 'received'" size="sm" variant="ghost" class="text-destructive hover:text-destructive" @click="withdraw(application)">Zurückziehen</Button>
</li>
</ul>
<div v-else class="rounded-lg border border-dashed bg-card"><EmptyState :icon="FileUser" title="Noch keine Bewerbungen" text="Offene Stellen finden Sie unter „Stellen“." /></div>
</AppLayout>
</template>

View file

@ -0,0 +1,148 @@
<script setup>
import { computed, ref, watch } from 'vue';
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
import { ArrowLeft, CircleCheck, ExternalLink, FileText, Mail, PencilLine, Phone, Send, Users } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import FormField from '@/components/FormField.vue';
import Panel from '@/components/Panel.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import { formatShortDate } from '@/lib/format';
import JobFacts from '../components/JobFacts.vue';
const props = defineProps({
posting: { type: Object, required: true },
application: { type: Object, default: null },
canApply: { type: Boolean, default: false },
editUrl: { type: String, default: null },
applicationsUrl: { type: String, default: null },
applicationsCount: { type: Number, default: null },
accept: { type: String, default: '.pdf' },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
const facts = computed(() => [
['Umfang', [props.posting.employment_label, props.posting.hours].filter(Boolean).join(', ')],
['Vertrag', props.posting.contract === 'fixed' ? `Befristet${props.posting.contract_note ? ` ${props.posting.contract_note}` : ''}` : 'Unbefristet'],
['Eingruppierung', props.posting.pay_grade],
['Beginn', props.posting.start],
['Bewerbungsfrist', props.posting.deadline ? formatShortDate(props.posting.deadline) : null],
].filter(([, value]) => value));
const statusLabel = { draft: 'Entwurf – nur für die Redaktion sichtbar', scheduled: 'Geplant – noch nicht sichtbar', expired: 'Frist abgelaufen – nicht mehr in der Liste' };
// Bewerben
const applying = ref(false);
const fileInput = ref(null);
const form = useForm({ message: '', file: null });
function apply() {
form.post(`/stellen/${props.posting.id}/bewerben`, { forceFormData: true, preserveScroll: true, onSuccess: () => (applying.value = false) });
}
function withdraw() {
if (window.confirm('Bewerbung zurückziehen? Nachricht und Unterlagen werden gelöscht.')) {
router.delete(`/stellen/bewerbungen/${props.application.id}`, { preserveScroll: true });
}
}
</script>
<template>
<AppLayout :title="posting.title">
<div class="mb-5 flex flex-wrap items-center justify-between gap-3">
<Link href="/stellen" class="inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Alle Stellen</Link>
<div class="flex flex-wrap gap-2">
<Button v-if="applicationsUrl" variant="outline" size="sm" as-child><Link :href="applicationsUrl"><Users /> Bewerbungen ({{ applicationsCount }})</Link></Button>
<Button v-if="editUrl" variant="outline" size="sm" as-child><Link :href="editUrl"><PencilLine /> Bearbeiten</Link></Button>
</div>
</div>
<p v-if="statusLabel[posting.status]" class="mb-4 rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950/50 dark:text-amber-100">{{ statusLabel[posting.status] }}</p>
<div class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]">
<article class="min-w-0 rounded-lg border bg-card p-6 sm:p-8">
<h1 class="text-2xl leading-tight font-semibold tracking-tight break-words sm:text-3xl">{{ posting.title }}</h1>
<JobFacts :posting="posting" class="mt-3" />
<div v-if="posting.description" class="prose prose-neutral mt-6 max-w-none break-words dark:prose-invert" v-html="posting.description" />
<a v-if="posting.pdf" :href="posting.pdf.url" target="_blank" rel="noopener" class="mt-6 inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-accent">
<FileText class="size-4 text-red-600" /> Ausschreibung als PDF <span class="text-xs font-normal text-muted-foreground">{{ posting.pdf.name }}</span>
</a>
</article>
<aside class="grid gap-6">
<!-- Bewerben -->
<Panel title="Bewerbung">
<template v-if="application">
<p class="flex items-center gap-2 text-sm font-medium text-emerald-700 dark:text-emerald-400"><CircleCheck class="size-4" /> Beworben am {{ formatShortDate(application.created_at) }}</p>
<p class="mt-1 text-sm">Stand: <strong>{{ application.status_label }}</strong></p>
<Button v-if="application.status === 'received'" variant="ghost" size="sm" class="mt-3 -ml-2 text-destructive hover:text-destructive" @click="withdraw">Bewerbung zurückziehen</Button>
</template>
<template v-else-if="posting.apply_mode === 'online'">
<p class="text-sm text-muted-foreground">Bewerben Sie sich direkt hier – vertraulich an {{ posting.contact ? posting.contact.name : 'die Personalabteilung' }}.</p>
<Button class="mt-4 w-full" :disabled="!canApply" @click="applying = true"><Send /> Jetzt bewerben</Button>
<p v-if="!canApply && posting.status !== 'open'" class="mt-2 text-xs text-muted-foreground">Bewerben ist gerade nicht möglich.</p>
</template>
<template v-else-if="posting.apply_mode === 'link' && posting.apply_url">
<Button class="w-full" as-child><a :href="posting.apply_url" target="_blank" rel="noopener"><ExternalLink /> Zur Bewerbung</a></Button>
</template>
<p v-else class="text-sm text-muted-foreground">Bitte wenden Sie sich an die Ansprechperson.</p>
<div v-if="posting.contact" class="mt-5 border-t pt-4">
<p class="mb-2 text-xs font-semibold tracking-wide text-muted-foreground uppercase">Ansprechperson</p>
<Link :href="`/personen/${posting.contact.id}`" class="flex items-center gap-3 hover:underline">
<PersonAvatar :person="posting.contact" class="size-10" />
<span class="min-w-0">
<span class="block text-sm font-medium">{{ posting.contact.name }}</span>
<span v-if="posting.contact.job_title" class="block truncate text-xs text-muted-foreground">{{ posting.contact.job_title }}</span>
</span>
</Link>
<p class="mt-2 grid gap-1 text-[13px]">
<a v-if="posting.contact.email" :href="`mailto:${posting.contact.email}`" class="inline-flex items-center gap-2 text-brand-text hover:underline"><Mail class="size-3.5" /> {{ posting.contact.email }}</a>
<a v-if="posting.contact.phone" :href="`tel:${posting.contact.phone}`" class="inline-flex items-center gap-2 text-brand-text hover:underline"><Phone class="size-3.5" /> {{ posting.contact.phone }}</a>
</p>
</div>
</Panel>
<Panel v-if="facts.length" title="Auf einen Blick">
<dl class="grid gap-3 text-sm">
<div v-for="[label, value] in facts" :key="label">
<dt class="text-xs text-muted-foreground">{{ label }}</dt>
<dd>{{ value }}</dd>
</div>
</dl>
</Panel>
</aside>
</div>
<Dialog v-model:open="applying">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Bewerbung: {{ posting.title }}</DialogTitle>
<DialogDescription>Ihre Angaben aus dem Profil (Name, Funktion, Abteilung) werden mitgeschickt. Vertraulich – nur für die Ansprechperson bzw. die Personalabteilung.</DialogDescription>
</DialogHeader>
<form class="grid gap-4" @submit.prevent="apply">
<FormField id="apply-message" label="Nachricht" :error="form.errors.message" hint="Warum interessiert Sie die Stelle? Was bringen Sie mit?">
<Textarea id="apply-message" v-model="form.message" rows="6" maxlength="5000" />
</FormField>
<FormField id="apply-file" label="Unterlagen (optional)" :error="form.errors.file" hint="z. B. Lebenslauf – PDF, Word oder OpenDocument, höchstens 10 MB.">
<div class="flex items-center gap-2">
<input id="apply-file" ref="fileInput" type="file" :accept="accept" class="hidden" @change="form.file = $event.target.files?.[0] ?? null" />
<Button type="button" variant="outline" size="sm" @click="fileInput?.click()">Datei auswählen</Button>
<span class="min-w-0 truncate text-[13px] text-muted-foreground">{{ form.file?.name ?? 'Keine Datei' }}</span>
</div>
</FormField>
<DialogFooter>
<Button type="button" variant="outline" @click="applying = false">Abbrechen</Button>
<Button type="submit" :disabled="form.processing || (!form.message.trim() && !form.file)"><Send /> Bewerbung senden</Button>
</DialogFooter>
<div v-if="form.progress" class="h-1 overflow-hidden rounded-full bg-muted"><div class="h-full bg-brand" :style="{ width: `${form.progress.percentage}%` }" /></div>
</form>
</DialogContent>
</Dialog>
</AppLayout>
</template>

View file

@ -0,0 +1,20 @@
<!doctype html>
<html lang="de">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"></head>
<body style="margin:0;background:#f4f5f7;font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1a1d21">
<div style="max-width:640px;margin:0 auto;padding:24px">
@php($branding = app(\App\Support\Branding::class))
<p style="margin:0 0 16px;font-size:15px;font-weight:700;color:{{ $branding->primaryColor() }}">{{ $portalName }}</p>
<div style="background:#fff;border:1px solid #e3e5e8;border-radius:8px;padding:24px">
<h1 style="margin:0 0 4px;font-size:20px">Neue Bewerbung</h1>
<p style="margin:0 0 16px;font-size:14px;color:#5f6670">{{ $posting->title }}</p>
<p style="margin:0;font-size:14px">
<strong>{{ $applicant->name }}</strong>@if ($applicant->job_title), {{ $applicant->job_title }}@endif@if ($applicant->department) ({{ $applicant->department }})@endif
hat sich auf die interne Stelle beworben.
</p>
<p style="margin:12px 0 0;font-size:14px">Nachricht und Unterlagen liegen aus Datenschutzgründen nur im Portal.</p>
<p style="margin:24px 0 0"><a href="{{ $url }}" style="display:inline-block;background:{{ $branding->primaryColor() }};color:{{ \App\Support\ColorPalette::foregroundFor($branding->primaryColor()) }};text-decoration:none;padding:10px 16px;border-radius:6px;font-size:14px">Bewerbung im Portal öffnen</a></p>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Route;
use Inhaus\Plugins\Stellen\Http\Controllers\JobController;
use Inhaus\Plugins\Stellen\Http\Controllers\JobEditorController;
Route::middleware('auth')->group(function () {
Route::prefix('stellen')->name('jobs.')->where(['posting' => '[0-9]+', 'application' => '[0-9]+'])->group(function () {
Route::get('/', [JobController::class, 'index'])->name('index');
Route::get('/meine-bewerbungen', [JobController::class, 'mine'])->name('mine');
Route::get('/{posting}', [JobController::class, 'show'])->name('show');
Route::get('/{posting}/ausschreibung.pdf', [JobController::class, 'pdf'])->name('pdf');
Route::post('/{posting}/bewerben', [JobController::class, 'apply'])->middleware('throttle:10,1')->name('apply');
Route::delete('/bewerbungen/{application}', [JobController::class, 'withdraw'])->name('withdraw');
Route::get('/bewerbungen/{application}/unterlagen', [JobController::class, 'file'])->name('applications.file');
});
Route::prefix('redaktion/stellen')->name('jobs.')->where(['posting' => '[0-9]+', 'application' => '[0-9]+'])->controller(JobEditorController::class)->group(function () {
Route::get('/neu', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('/{posting}', 'edit')->name('edit');
Route::post('/{posting}', 'update')->name('update'); // POST wegen PDF-Upload
Route::delete('/{posting}', 'destroy')->name('destroy');
Route::get('/{posting}/bewerbungen', 'applications')->name('applications');
Route::put('/bewerbungen/{application}', 'updateApplication')->name('applications.update');
});
});

View file

@ -0,0 +1,40 @@
<?php
namespace Inhaus\Plugins\Stellen;
use App\Models\User;
use App\Notifications\PortalNotification;
use Illuminate\Support\Facades\Notification;
use Inhaus\Plugins\Stellen\Models\JobPosting;
/**
* Neue Stellen einmalig ankündigen (Glocke und Push an alle aktiven Personen).
* Geplante Stellen werden angekündigt, sobald sie erscheinen.
*/
class Announcer
{
public function announceIfDue(JobPosting $posting): void
{
if ($posting->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',
);
User::query()->active()->whereKeyNot($posting->created_by ?? 0)->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();
}
}

View file

@ -0,0 +1,143 @@
<?php
namespace Inhaus\Plugins\Stellen\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Notifications\PortalNotification;
use App\Support\Audit;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\File;
use Inertia\Inertia;
use Inertia\Response;
use Inhaus\Plugins\Stellen\Mail\ApplicationReceived;
use Inhaus\Plugins\Stellen\Models\JobApplication;
use Inhaus\Plugins\Stellen\Models\JobPosting;
use Inhaus\Plugins\Stellen\Presenter;
use Symfony\Component\HttpFoundation\StreamedResponse;
class JobController extends Controller
{
public const EXTENSIONS = ['pdf', 'doc', 'docx', 'odt'];
public function index(Request $request): Response
{
$postings = JobPosting::query()->open()->orderByDesc('published_at')->get();
$applied = JobApplication::query()->where('user_id', $request->user()->id)->pluck('posting_id')->all();
return Inertia::render('stellen::Index', [
'postings' => $postings->map(fn (JobPosting $p) => [...Presenter::card($p), 'applied' => in_array($p->id, $applied, true)])->values(),
'filters' => [
'departments' => $postings->pluck('department')->filter()->unique()->sort()->values(),
'locations' => $postings->pluck('location')->filter()->unique()->sort()->values(),
'employments' => collect(JobPosting::EMPLOYMENT)->only($postings->pluck('employment')->unique())->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
],
'canManage' => $request->user()->can('jobs.manage'),
'myApplications' => count($applied),
]);
}
public function show(Request $request, JobPosting $posting): Response
{
$user = $request->user();
abort_unless($posting->isOpen() || $user->can('jobs.manage') || $posting->canSeeApplications($user), 404);
$mine = JobApplication::query()->where('posting_id', $posting->id)->where('user_id', $user->id)->first();
return Inertia::render('stellen::Show', [
'posting' => Presenter::detail($posting->load('contact'), $user),
'application' => $mine ? Presenter::application($mine) : null,
'canApply' => $posting->isOpen() && $posting->apply_mode === 'online' && ! $mine,
'editUrl' => $user->can('jobs.manage') ? route('jobs.edit', $posting) : null,
'applicationsUrl' => $posting->canSeeApplications($user) ? route('jobs.applications', $posting) : null,
'applicationsCount' => $posting->canSeeApplications($user) ? $posting->applications()->count() : null,
'accept' => '.'.implode(',.', self::EXTENSIONS),
]);
}
public function pdf(Request $request, JobPosting $posting): StreamedResponse
{
abort_unless($posting->pdf_path && ($posting->isOpen() || $request->user()->can('jobs.manage') || $posting->canSeeApplications($request->user())), 404);
return Storage::disk(JobPosting::DISK)->response($posting->pdf_path, $posting->pdf_name, ['Content-Type' => 'application/pdf', 'X-Content-Type-Options' => 'nosniff']);
}
public function apply(Request $request, JobPosting $posting): RedirectResponse
{
abort_unless($posting->isOpen() && $posting->apply_mode === 'online', 404);
$user = $request->user();
abort_if(JobApplication::query()->where('posting_id', $posting->id)->where('user_id', $user->id)->exists(), 422, 'Sie haben sich bereits beworben.');
$data = $request->validate([
'message' => ['nullable', 'string', 'max:5000', 'required_without:file'],
'file' => ['nullable', File::types(self::EXTENSIONS)->max(10 * 1024)],
], ['message.required_without' => 'Bitte eine Nachricht schreiben oder eine Datei anhängen.', 'file.mimes' => 'Bitte eine PDF-, Word- oder OpenDocument-Datei anhängen.'], ['message' => 'Nachricht', 'file' => 'Anhang']);
$file = $request->file('file');
$application = JobApplication::query()->create([
'posting_id' => $posting->id,
'user_id' => $user->id,
'message' => filled($data['message'] ?? null) ? trim($data['message']) : null,
'file_path' => $file?->storeAs('stellen/bewerbungen/'.$posting->id, Str::random(32).'.'.strtolower($file->getClientOriginalExtension()), JobPosting::DISK),
'file_name' => $file ? Str::limit(preg_replace('/[^\pL\pN ._()\-]+/u', '_', $file->getClientOriginalName()) ?: 'bewerbung', 180, '') : null,
]);
Audit::log('jobs.applied', ['posting' => $posting->id, 'application' => $application->id]);
$this->notifyRecipients($posting, $application, $user);
return back()->with('status', 'Danke – Ihre Bewerbung ist eingegangen. Den Stand sehen Sie hier und unter „Meine Bewerbungen“.');
}
public function withdraw(Request $request, JobApplication $application): RedirectResponse
{
abort_unless($application->user_id === $request->user()->id, 403);
$application->delete();
Audit::log('jobs.withdrawn', ['posting' => $application->posting_id]);
return back()->with('status', 'Ihre Bewerbung wurde zurückgezogen und gelöscht.');
}
public function mine(Request $request): Response
{
$applications = JobApplication::query()->where('user_id', $request->user()->id)->with('posting')->latest()->get();
return Inertia::render('stellen::Mine', [
'applications' => $applications->map(fn (JobApplication $a) => [...Presenter::application($a), 'posting' => Presenter::card($a->posting)])->values(),
]);
}
public function file(Request $request, JobApplication $application): StreamedResponse
{
$user = $request->user();
abort_unless($application->file_path && ($application->user_id === $user->id || $application->posting->canSeeApplications($user)), 404);
return Storage::disk(JobPosting::DISK)->download($application->file_path, $application->file_name, ['X-Content-Type-Options' => 'nosniff']);
}
/**
* Ansprechperson der Stelle – ohne sie alle mit „Bewerbungen einsehen“ – im Portal,
* dazu optional per E-Mail (ohne Anhang, nur mit Link ins Portal).
*/
private function notifyRecipients(JobPosting $posting, JobApplication $application, User $applicant): void
{
$recipients = $posting->contact?->is_active
? collect([$posting->contact])
: User::query()->active()->whereHas('roles.grants', fn ($g) => $g->where('ability', 'jobs.applications'))->get();
Notification::send($recipients, new PortalNotification(
'Neue Bewerbung: '.$posting->title,
$applicant->name.($applicant->department ? ' ('.$applicant->department.')' : '').' hat sich beworben.',
route('jobs.applications', $posting, false),
'briefcase',
));
if ($posting->notify_email) {
Mail::to($posting->notify_email)->queue(new ApplicationReceived($posting, $applicant));
}
}
}

View file

@ -0,0 +1,203 @@
<?php
namespace Inhaus\Plugins\Stellen\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Notifications\PortalNotification;
use App\Pagebuilder\Field;
use App\Support\Audit;
use App\Support\RichText;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\File;
use Inertia\Inertia;
use Inertia\Response;
use Inhaus\Plugins\Stellen\Announcer;
use Inhaus\Plugins\Stellen\Models\JobApplication;
use Inhaus\Plugins\Stellen\Models\JobPosting;
use Inhaus\Plugins\Stellen\Presenter;
/**
* Stellen ausschreiben und Bewerbungen bearbeiten (Personalabteilung).
*/
class JobEditorController extends Controller
{
public function create(Request $request): Response
{
$this->authorizeManage($request);
return $this->editor(null);
}
public function edit(Request $request, JobPosting $posting): Response
{
$this->authorizeManage($request);
return $this->editor($posting->load('contact'));
}
public function store(Request $request, Announcer $announcer): RedirectResponse
{
$this->authorizeManage($request);
$posting = JobPosting::query()->create([...$this->validated($request), 'created_by' => $request->user()->id, 'updated_by' => $request->user()->id]);
$this->storePdf($request, $posting);
Audit::log('jobs.created', ['posting' => $posting->id, 'title' => $posting->title]);
$announcer->announceIfDue($posting);
return to_route('jobs.show', $posting)->with('status', $posting->isOpen() ? 'Stelle veröffentlicht – alle werden benachrichtigt.' : 'Stelle gespeichert.');
}
public function update(Request $request, JobPosting $posting, Announcer $announcer): RedirectResponse
{
$this->authorizeManage($request);
$posting->update([...$this->validated($request), 'updated_by' => $request->user()->id]);
$this->storePdf($request, $posting);
Audit::log('jobs.updated', ['posting' => $posting->id, 'title' => $posting->title]);
$announcer->announceIfDue($posting);
return to_route('jobs.show', $posting)->with('status', 'Stelle gespeichert.');
}
public function destroy(Request $request, JobPosting $posting): RedirectResponse
{
$this->authorizeManage($request);
$posting->delete();
Audit::log('jobs.deleted', ['posting' => $posting->id, 'title' => $posting->title]);
return to_route('jobs.index')->with('status', 'Stelle „'.$posting->title.'“ und ihre Bewerbungen gelöscht.');
}
public function applications(Request $request, JobPosting $posting): Response
{
abort_unless($posting->canSeeApplications($request->user()), 403);
return Inertia::render('stellen::Applications', [
'posting' => Presenter::card($posting),
'applications' => $posting->applications()->with('user')->latest()->get()->map(fn (JobApplication $a) => Presenter::application($a, withPerson: true))->values(),
'statuses' => collect(JobApplication::STATUSES)->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
]);
}
public function updateApplication(Request $request, JobApplication $application): RedirectResponse
{
abort_unless($application->posting->canSeeApplications($request->user()), 403);
$data = $request->validate(['status' => ['required', Rule::in(array_keys(JobApplication::STATUSES))], 'note' => ['nullable', 'string', 'max:5000']]);
$changed = $application->status !== $data['status'];
$application->update($data);
Audit::log('jobs.application_updated', ['application' => $application->id, 'status' => $data['status']]);
// Die bewerbende Person sieht den neuen Stand (nicht die interne Notiz)
if ($changed) {
$application->user?->notify(new PortalNotification(
'Ihre Bewerbung: '.$application->posting->title,
'Neuer Stand: '.JobApplication::STATUSES[$data['status']].'.',
route('jobs.mine', [], false),
'briefcase',
));
}
return back()->with('status', 'Gespeichert.');
}
private function editor(?JobPosting $posting): Response
{
return Inertia::render('stellen::Editor', [
'posting' => $posting ? [
...$posting->only(['id', 'title', 'department', 'location', 'employment', 'hours', 'contract', 'contract_note', 'pay_grade', 'start', 'description', 'apply_mode', 'apply_url', 'notify_email']),
'deadline' => $posting->deadline?->toDateString(),
'published_at' => $posting->published_at?->format('Y-m-d\TH:i'),
'status' => $posting->status(),
'pdf_name' => $posting->pdf_name,
'contact' => $posting->contact ? ['id' => $posting->contact->id, 'name' => $posting->contact->name, 'initials' => $posting->contact->initials, 'job_title' => $posting->contact->job_title, 'avatar_url' => $posting->contact->avatarUrl(96)] : null,
'applications' => $posting->applications()->count(),
] : null,
'options' => [
'employment' => collect(JobPosting::EMPLOYMENT)->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
'contract' => collect(JobPosting::CONTRACT)->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
'apply_modes' => collect(JobPosting::APPLY_MODES)->map(fn ($label, $value) => ['value' => $value, 'label' => $label])->values(),
'departments' => JobPosting::query()->whereNotNull('department')->distinct()->orderBy('department')->pluck('department'),
'locations' => JobPosting::query()->whereNotNull('location')->distinct()->orderBy('location')->pluck('location'),
],
]);
}
/**
* @return array<string, mixed>
*/
private function validated(Request $request): array
{
$data = $request->validate([
'title' => ['required', 'string', 'max:200'],
'department' => ['nullable', 'string', 'max:150'],
'location' => ['nullable', 'string', 'max:150'],
'employment' => ['required', Rule::in(array_keys(JobPosting::EMPLOYMENT))],
'hours' => ['nullable', 'string', 'max:60'],
'contract' => ['required', Rule::in(array_keys(JobPosting::CONTRACT))],
'contract_note' => ['nullable', 'string', 'max:120'],
'pay_grade' => ['nullable', 'string', 'max:60'],
'start' => ['nullable', 'string', 'max:60'],
'deadline' => ['nullable', 'date'],
'description' => ['nullable', 'string', 'max:200000'],
'apply_mode' => ['required', Rule::in(array_keys(JobPosting::APPLY_MODES))],
'apply_url' => ['nullable', 'required_if:apply_mode,link', 'string', 'max:1000'],
'contact_id' => ['nullable', 'integer', Rule::exists('users', 'id')],
'notify_email' => ['nullable', 'email', 'max:190'],
'publish' => ['required', Rule::in(['draft', 'now', 'at'])],
'published_at' => ['nullable', 'required_if:publish,at', 'date'],
'pdf' => ['nullable', File::types(['pdf'])->max(20 * 1024)],
'remove_pdf' => ['boolean'],
], ['apply_url.required_if' => 'Bitte die Adresse angeben, unter der man sich bewirbt.', 'published_at.required_if' => 'Bitte Datum und Uhrzeit angeben.'], [
'title' => 'Titel', 'deadline' => 'Bewerbungsfrist', 'apply_url' => 'Link', 'notify_email' => 'E-Mail', 'pdf' => 'PDF',
]);
$url = $data['apply_mode'] === 'link' ? Field::safeUrl($data['apply_url'] ?? '') : '';
return [
'title' => trim($data['title']),
...collect($data)->only(['department', 'location', 'hours', 'contract_note', 'pay_grade', 'start'])->map(fn ($v) => filled($v) ? trim($v) : null)->all(),
'employment' => $data['employment'],
'contract' => $data['contract'],
'deadline' => $data['deadline'] ?? null,
'description' => filled($data['description'] ?? null) ? app(RichText::class)->sanitize($data['description']) : null,
'apply_mode' => $data['apply_mode'],
'apply_url' => $url !== '' ? $url : null,
'contact_id' => $data['contact_id'] ?? null,
'notify_email' => $data['notify_email'] ?? null,
'published_at' => match ($data['publish']) {
'now' => $request->route('posting')?->published_at?->isPast() ? $request->route('posting')->published_at : now(),
'at' => Carbon::parse($data['published_at']),
default => null,
},
];
}
private function storePdf(Request $request, JobPosting $posting): void
{
if ($request->boolean('remove_pdf') || $request->hasFile('pdf')) {
if ($posting->pdf_path) {
Storage::disk(JobPosting::DISK)->delete($posting->pdf_path);
}
$posting->forceFill(['pdf_path' => null, 'pdf_name' => null]);
}
if ($file = $request->file('pdf')) {
$posting->forceFill([
'pdf_path' => $file->storeAs('stellen/ausschreibungen', Str::random(32).'.pdf', JobPosting::DISK),
'pdf_name' => Str::limit(preg_replace('/[^\pL\pN ._()\-]+/u', '_', $file->getClientOriginalName()) ?: 'ausschreibung.pdf', 180, ''),
]);
}
$posting->save();
}
private function authorizeManage(Request $request): void
{
abort_unless($request->user()->can('jobs.manage'), 403);
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace Inhaus\Plugins\Stellen;
use App\Models\User;
use App\Search\GlobalSearch;
use Inhaus\Plugins\Stellen\Models\JobPosting;
/** Suchquelle: offene Stellen */
class JobSearch
{
/**
* @return list<array<string, mixed>>
*/
public function __invoke(User $user, string $search, int $limit): array
{
$query = JobPosting::query()->open();
GlobalSearch::whereTerms($query, ['title', 'department', 'location', 'description'], $search);
return $query->orderByDesc('published_at')->limit($limit)->get()->map(fn (JobPosting $p) => [
'title' => $p->title,
'url' => '/stellen/'.$p->id,
'excerpt' => GlobalSearch::excerpt(strip_tags((string) $p->description), $search),
'meta' => collect([$p->department, $p->location, $p->deadline ? 'Frist '.$p->deadline->format('d.m.Y') : null])->filter()->implode(' · '),
])->all();
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace Inhaus\Plugins\Stellen\Mail;
use App\Models\User;
use App\Support\Branding;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Inhaus\Plugins\Stellen\Models\JobPosting;
/**
* Hinweis auf eine neue Bewerbung – ohne Anhang, die Unterlagen liegen vertraulich im Portal.
*/
class ApplicationReceived extends Mailable implements ShouldQueue
{
use Queueable;
use SerializesModels;
public function __construct(public JobPosting $posting, public User $applicant) {}
public function envelope(): Envelope
{
return new Envelope(subject: 'Neue Bewerbung: '.$this->posting->title, replyTo: [$this->applicant->email]);
}
public function content(): Content
{
return new Content(view: 'stellen::mail.application', with: [
'portalName' => app(Branding::class)->portalName(),
'url' => route('jobs.applications', $this->posting),
]);
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace Inhaus\Plugins\Stellen\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;
/**
* Bewerbung auf eine interne Stelle – vertraulich: sichtbar für die bewerbende Person,
* die Ansprechperson der Stelle und alle mit „Bewerbungen einsehen“.
*/
#[Fillable(['posting_id', 'user_id', 'message', 'file_path', 'file_name', 'status', 'note', 'withdrawn_at'])]
class JobApplication extends Model
{
public const STATUSES = ['received' => 'Eingegangen', 'review' => 'In Prüfung', 'interview' => 'Gespräch vereinbart', 'closed' => 'Abgeschlossen'];
protected static function booted(): void
{
static::deleting(function (JobApplication $application) {
if ($application->file_path) {
Storage::disk(JobPosting::DISK)->delete($application->file_path);
}
});
}
protected function casts(): array
{
return ['withdrawn_at' => 'datetime'];
}
/**
* @return BelongsTo<JobPosting, $this>
*/
public function posting(): BelongsTo
{
return $this->belongsTo(JobPosting::class, 'posting_id');
}
/**
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}

View file

@ -0,0 +1,102 @@
<?php
namespace Inhaus\Plugins\Stellen\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;
/**
* Eine interne Stellenausschreibung. Sichtbar ab „published_at“ bis einschließlich zur Frist.
*/
#[Fillable(['title', 'department', 'location', 'employment', 'hours', 'contract', 'contract_note', 'pay_grade', 'start', 'deadline',
'description', 'pdf_path', 'pdf_name', 'apply_mode', 'apply_url', 'contact_id', 'notify_email', 'published_at', 'created_by', 'updated_by'])]
class JobPosting extends Model
{
public const DISK = 'local';
public const EMPLOYMENT = ['full' => 'Vollzeit', 'part' => 'Teilzeit', 'flex' => 'Voll- oder Teilzeit', 'mini' => 'Minijob', 'training' => 'Ausbildung / Studium', 'other' => 'Sonstiges'];
public const CONTRACT = ['permanent' => 'Unbefristet', 'fixed' => 'Befristet'];
public const APPLY_MODES = ['online' => 'Online im Portal', 'contact' => 'Über die Ansprechperson', 'link' => 'Über einen Link'];
protected static function booted(): void
{
static::deleting(function (JobPosting $posting) {
if ($posting->pdf_path) {
Storage::disk(self::DISK)->delete($posting->pdf_path);
}
$posting->applications()->get()->each->delete();
});
}
protected function casts(): array
{
return ['deadline' => 'date', 'published_at' => 'datetime', 'announced_at' => 'datetime'];
}
/**
* Offene Stellen: veröffentlicht und Frist nicht abgelaufen.
*
* @param Builder<JobPosting> $query
*/
public function scopeOpen(Builder $query): void
{
$query->whereNotNull('published_at')->where('published_at', '<=', now())
->where(fn (Builder $q) => $q->whereNull('deadline')->orWhereDate('deadline', '>=', today()));
}
public function isOpen(): bool
{
return $this->published_at !== null && $this->published_at->isPast() && ($this->deadline === null || ! $this->deadline->isBefore(today()));
}
public function status(): string
{
return match (true) {
$this->published_at === null => 'draft',
$this->published_at->isFuture() => 'scheduled',
$this->deadline !== null && $this->deadline->isBefore(today()) => 'expired',
default => 'open',
};
}
/**
* @return BelongsTo<User, $this>
*/
public function contact(): BelongsTo
{
return $this->belongsTo(User::class, 'contact_id');
}
/**
* @return HasMany<JobApplication, $this>
*/
public function applications(): HasMany
{
return $this->hasMany(JobApplication::class, 'posting_id');
}
/** Wer die Bewerbungen dieser Stelle sehen darf */
public function canSeeApplications(?User $user): bool
{
return $user !== null && ($user->can('jobs.applications') || ($this->contact_id !== null && $this->contact_id === $user->id));
}
/**
* Kurzfassung der Eckdaten, z. B. „Teilzeit (30 Std./Woche) · befristet bis 31.12.2027“.
*/
public function summary(): string
{
return collect([
self::EMPLOYMENT[$this->employment] ?? null,
$this->hours ? '('.$this->hours.')' : null,
])->filter()->implode(' ').($this->contract === 'fixed' ? ' · befristet'.($this->contract_note ? ' '.$this->contract_note : '') : '');
}
}

View file

@ -0,0 +1,81 @@
<?php
namespace Inhaus\Plugins\Stellen;
use App\Models\User;
use Inhaus\Plugins\Stellen\Models\JobApplication;
use Inhaus\Plugins\Stellen\Models\JobPosting;
/**
* Daten der Stellen für das Portal.
*/
class Presenter
{
/**
* @return array<string, mixed>
*/
public static function card(JobPosting $posting): array
{
return [
'id' => $posting->id,
'title' => $posting->title,
'department' => $posting->department,
'location' => $posting->location,
'employment' => $posting->employment,
'employment_label' => JobPosting::EMPLOYMENT[$posting->employment] ?? null,
'summary' => $posting->summary(),
'deadline' => $posting->deadline?->toDateString(),
'published_at' => $posting->published_at?->toIso8601String(),
'status' => $posting->status(),
'url' => route('jobs.show', $posting),
];
}
/**
* @return array<string, mixed>
*/
public static function detail(JobPosting $posting, User $viewer): array
{
$contact = $posting->contact?->is_active ? $posting->contact : null;
return [
...self::card($posting),
'hours' => $posting->hours,
'contract' => $posting->contract,
'contract_label' => JobPosting::CONTRACT[$posting->contract] ?? null,
'contract_note' => $posting->contract_note,
'pay_grade' => $posting->pay_grade,
'start' => $posting->start,
'description' => $posting->description,
'pdf' => $posting->pdf_path ? ['name' => $posting->pdf_name, 'url' => route('jobs.pdf', $posting)] : null,
'apply_mode' => $posting->apply_mode,
'apply_url' => $posting->apply_mode === 'link' ? $posting->apply_url : null,
'contact' => $contact ? [
'id' => $contact->id, 'name' => $contact->name, 'initials' => $contact->initials, 'job_title' => $contact->job_title,
'email' => $contact->email, 'phone' => $contact->phone, 'avatar_url' => $contact->avatarUrl(96),
] : null,
];
}
/**
* @return array<string, mixed>
*/
public static function application(JobApplication $application, bool $withPerson = false): array
{
return [
'id' => $application->id,
'status' => $application->status,
'status_label' => JobApplication::STATUSES[$application->status] ?? $application->status,
'message' => $application->message,
'file' => $application->file_path ? ['name' => $application->file_name, 'url' => route('jobs.applications.file', $application)] : null,
'created_at' => $application->created_at?->toIso8601String(),
'updated_at' => $application->updated_at?->toIso8601String(),
'note' => $withPerson ? $application->note : null,
'person' => $withPerson && $application->user ? [
'id' => $application->user->id, 'name' => $application->user->name, 'initials' => $application->user->initials,
'job_title' => $application->user->job_title, 'department' => $application->user->department,
'email' => $application->user->email, 'avatar_url' => $application->user->avatarUrl(96),
] : null,
];
}
}

View file

@ -0,0 +1,40 @@
<?php
namespace Inhaus\Plugins\Stellen;
use App\Editorial\Editorial;
use App\Models\User;
use App\Plugins\Plugin;
use App\Search\GlobalSearch;
use App\Support\Abilities;
use App\Support\Navigation;
use Illuminate\Support\Facades\Schedule;
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);
$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);
$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'),
]);
}
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);
}
}