Verleih 1.0.0: Verleihsystem für Inhaus

Übersicht mit Status und Standort, Anfragen im Portal (Benachrichtigung +
E-Mail ans Team), Zusagen/Absagen mit automatischem Eintrag, Zurücknehmen,
Recht „Verleih verwalten“, einstellbare Bezeichnungen und Übernahme aus dem
WordPress-Plugin „FL-Verleihsystem“ (WXR mit Bildern).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-28 15:17:47 +00:00
commit 14aaa16b30
47 changed files with 4208 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules/
*.zip

45
README.md Normal file
View file

@ -0,0 +1,45 @@
# Verleih – Plugin für Inhaus
Verleihsystem für das Mitarbeiterportal **Inhaus** – gebaut für die Bilder des Künstlerteams,
aber für alles nutzbar, was verliehen wird (Bezeichnungen im Backend einstellbar).
- **Übersicht** `/verleih`: alle Bilder mit Status (verfügbar / verliehen) und aktuellem Standort,
verfügbare zuerst, Filter und Suche. Kunstwerke werden nie beschnitten.
- **Anfragen im Portal** statt E-Mail-Links: „Bild anfragen“ mit Wunschort, optionalem Zeitraum und
Nachricht. Das Team bekommt eine Benachrichtigung im Portal und eine E-Mail (Antworten gehen direkt
an die anfragende Person).
- **Zusagen / Absagen** unter `/verleih/anfragen` (und in der Redaktion): Eine Zusage trägt das Bild
gleich als verliehen ein – Ort, Person, Zeitraum. Die anfragende Person wird benachrichtigt.
„Zurückgenommen“ macht es wieder verfügbar, mit neuem Standort.
- **Recht** „Verleih verwalten“ (`verleih.manage`) – z. B. der Rolle „Künstlerteam“ geben.
Wer das Bild gerade hat, sehen nur Personen mit diesem Recht.
- **Übernahme aus WordPress** (Plugin „FL-Verleihsystem“): Administration → Portal → Verleih →
„Aus WordPress übernehmen“. Datei aus WordPress unter „Werkzeuge → Daten exportieren → Objekte“.
Übernommen werden Titel, Beschreibung, Beitragsbild, `_bv_verliehen` und `_bv_verleihort` von
veröffentlichten Objekten. Ein zweiter Lauf überschreibt nichts. Bilder werden von der alten Seite
geladen (nur öffentlich erreichbare Adressen) – bei vielen Bildern „Bilder nachladen“ wiederholen.
Voraussetzung: Inhaus ab 0.42.0.
## Installation
1. Neuestes Release herunterladen: `verleih-<version>.zip` unter
<https://git.loheide.cloud/friloo/inhaus-plugin-verleih/releases>
2. Administration → Plugins → „Plugin hochladen“, danach aktivieren.
3. Unter Benutzer & Rechte → Rollen einer Rolle (z. B. „Künstlerteam“) das Recht „Verleih verwalten“ geben.
Updates erscheinen danach automatisch unter Administration → Plugins.
## Entwicklung
```bash
npm install
npm run build # dist/ – wird mit ins Repository eingecheckt
npm run package # baut und erzeugt verleih-<version>.zip
```
Tests laufen in einer Inhaus-Installation, in der das Plugin unter `plugins/verleih` liegt (Kopie oder Symlink):
```bash
vendor-dev/bin/phpunit plugins/verleih/tests
```

29
bin/package Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php
/**
* Baut verleih-<version>.zip zum Hochladen unter Administration → Plugins.
* Enthält alles außer Quelltexten fürs Frontend-Build und node_modules.
*/
$root = dirname(__DIR__);
$manifest = json_decode(file_get_contents("{$root}/plugin.json"), true);
$target = "{$root}/verleih-{$manifest['version']}.zip";
$skip = ['node_modules', '.git', 'inhaus-sdk', 'package.json', 'package-lock.json', 'vite.config.js', basename($target)];
@unlink($target);
$zip = new ZipArchive;
$zip->open($target, ZipArchive::CREATE);
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root, FilesystemIterator::SKIP_DOTS));
foreach ($files as $file) {
$relative = substr($file->getPathname(), strlen($root) + 1);
if (in_array(explode(DIRECTORY_SEPARATOR, $relative)[0], $skip, true) || str_ends_with($relative, '.zip')) {
continue;
}
$zip->addFile($file->getPathname(), 'verleih/'.$relative);
}
$zip->close();
echo "Paket: {$target}\n";

View file

@ -0,0 +1,53 @@
<?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
{
// Objekte (z. B. Bilder des Künstlerteams) mit Verleihstatus und aktuellem Standort
Schema::create('verleih_items', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('description')->nullable();
$table->string('image_path')->nullable();
$table->string('thumb_path')->nullable();
$table->unsignedSmallInteger('image_width')->nullable();
$table->unsignedSmallInteger('image_height')->nullable();
$table->boolean('lent')->default(false)->index();
$table->string('location')->nullable();
$table->foreignId('lent_to_id')->nullable()->constrained('users')->nullOnDelete();
$table->date('lent_since')->nullable();
$table->date('lent_until')->nullable();
// Import aus dem WordPress-Verleihsystem: Beitrags-ID und Bildadresse (für „Bilder nachladen“)
$table->unsignedBigInteger('wp_id')->nullable()->unique();
$table->string('wp_image_url', 1000)->nullable();
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
});
Schema::create('verleih_requests', function (Blueprint $table) {
$table->id();
$table->foreignId('item_id')->constrained('verleih_items')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->string('location', 200);
$table->date('from')->nullable();
$table->date('until')->nullable();
$table->text('message')->nullable();
$table->string('status', 16)->default('pending')->index(); // pending, accepted, declined, cancelled
$table->foreignId('decided_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('decided_at')->nullable();
$table->string('note', 1000)->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('verleih_requests');
Schema::dropIfExists('verleih_items');
}
};

2
dist/assets/style-DpnhOE_3.css vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/chunks/StatusBadge-CZaj6wAi.js vendored Normal file
View file

@ -0,0 +1 @@
import{t as e}from"./createLucideIcon-CYyWUN7r.js";import{createElementBlock as t,createElementVNode as n,createTextVNode as r,normalizeClass as i,openBlock as a,toDisplayString as o}from"vue";var s=e({name:`image-off`,size:24,node:[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]}),c=e({name:`map-pin`,size:24,node:[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]}),l={__name:`StatusBadge`,props:{lent:{type:Boolean,required:!0}},setup(e){return(s,c)=>(a(),t(`span`,{class:i([`ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:px-2 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:shadow-xs`,e.lent?`ih:bg-card ih:text-muted-foreground`:`ih:bg-brand ih:text-brand-foreground`])},[n(`span`,{class:i([`ih:size-1.5 ih:rounded-full`,e.lent?`ih:bg-muted-foreground`:`ih:bg-brand-foreground`]),"aria-hidden":`true`},null,2),r(` `+o(e.lent?`Verliehen`:`Verfügbar`),1)],2))}};export{c as n,s as r,l as t};

View file

@ -0,0 +1 @@
import{h as e,inject as t}from"vue";var n={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`},r=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim();function i(e){return e!=null}function a(e,t={}){let a=t.attributeNames??{},o=e=>a[e]??e,s=e.size??e.width??n.width,c=e.size??e.height??n.height,l=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],u=[...e.name?[`lucide-${e.name}`]:[],...l],d=t.className?.split(` `).filter(Boolean)??[],f=t.includeDefaultClasses===!1?r(...d):r(`lucide`,...u,...d),p=t.absoluteStrokeWidth?Number(t.strokeWidth??n[`stroke-width`])*Number(e.size??e.width??n.width)/Number(t.size??t.width??n.width):t.strokeWidth??n[`stroke-width`];return[`svg`,{...Object.entries(n).reduce((e,[t,n])=>(e[o(t)]=n,e),{}),...`color`in t&&t.color&&{[o(`stroke`)]:t.color},...`size`in t&&i(t.size)&&{[o(`width`)]:t.size,[o(`height`)]:t.size},...`width`in t&&i(t.width)&&{[o(`width`)]:t.width},...`height`in t&&i(t.height)&&{[o(`height`)]:t.height},[o(`stroke-width`)]:p,...f&&{[o(`class`)]:f},[o(`viewBox`)]:`0 0 ${s} ${c}`,...t.hasA11yProp===!1?{[o(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,r,i]=e,a=t.nonScalingStroke?{[o(`vector-effect`)]:`non-scaling-stroke`,...r}:r;return i?[n,a,i]:[n,a]})]}var o=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},s=e=>e===``,c=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),l=Symbol(`lucide-icons`);function u(){return t(l,{})}var d=({name:t,iconNode:n,"icon-node":r,icon:i={name:t&&c(t),node:n??r??[],size:24,aliases:[]},absoluteStrokeWidth:l,"absolute-stroke-width":d,nonScalingStroke:f,"non-scaling-stroke":p,strokeWidth:m,"stroke-width":h,size:g,width:_=g,height:v=g,color:y,...b},{slots:x})=>{let{size:S,color:C,strokeWidth:w=2,absoluteStrokeWidth:T=!1,nonScalingStroke:E=!1,class:D=``}=u(),O=s(l)||s(d)||l===!0||d===!0||T===!0,k=s(f)||s(p)||f===!0||p===!0||E===!0;delete b.class;let A=x.default?.(),[,j,M=[]]=a(i,{color:y??C,width:_??g??S,height:v??g??S,strokeWidth:m??h??w,absoluteStrokeWidth:O,nonScalingStroke:k,className:D,hasA11yProp:A!=null&&A.length>0||o(b),attributes:b});return e(`svg`,j,[...M.map(([t,n])=>e(t,n)),...A??[]])};function f(t,n=[]){let r=typeof t==`string`?{name:t,node:n}:t;return(t,{slots:n})=>e(d,{...t,icon:r},n.default?{default:n.default}:void 0)}export{f as t};

1
dist/chunks/inbox-CWQqWjak.js vendored Normal file
View file

@ -0,0 +1 @@
import{t as e}from"./createLucideIcon-CYyWUN7r.js";var t=e({name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]});export{t};

1
dist/chunks/loader-circle-DBP4Qhm5.js vendored Normal file
View file

@ -0,0 +1 @@
import{t as e}from"./createLucideIcon-CYyWUN7r.js";var t=e({name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]}),n=e({name:`loader-circle`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]],aliases:[`loader-2`]});export{t as n,n as t};

1
dist/chunks/trash-COMUOW6h.js vendored Normal file
View file

@ -0,0 +1 @@
import{t as e}from"./createLucideIcon-CYyWUN7r.js";var t=e({name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]});export{t};

1
dist/chunks/x-CV132X1X.js vendored Normal file
View file

@ -0,0 +1 @@
import{t as e}from"./createLucideIcon-CYyWUN7r.js";var t=e({name:`calendar-days`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M8 13h.01`,key:`1sbv64`}],[`path`,{d:`M12 13h.01`,key:`y0uutt`}],[`path`,{d:`M16 13h.01`,key:`wip0gl`}],[`path`,{d:`M8 17h.01`,key:`p3bg7i`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M16 17h.01`,key:`ql8jdd`}]]}),n=e({name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]});export{t as n,n as t};

1
dist/editorial/EditorialRequests.js vendored Normal file
View file

@ -0,0 +1 @@
import{Fragment as e,createBlock as t,createCommentVNode as n,createElementBlock as r,createElementVNode as i,createTextVNode as a,createVNode as o,openBlock as s,renderList as c,toDisplayString as l,unref as u,withCtx as d}from"vue";import{Link as f}from"@inertiajs/vue3";import{Panel as p,formatRelative as m}from"@inhaus/ui";var h={key:0,class:`ih:-mx-5 ih:divide-y ih:border-t`},g=[`src`],_={class:`ih:min-w-0 ih:flex-1`},v={class:`ih:truncate ih:text-xs ih:text-muted-foreground`},y={class:`ih:shrink-0 ih:text-xs ih:text-muted-foreground`},b={key:1,class:`ih:text-sm ih:text-muted-foreground`},x={__name:`EditorialRequests`,props:{pending:{type:Array,required:!0}},setup(x){return(S,C)=>(s(),t(u(p),{title:`Verleih – offene Anfragen`,"action-label":`Zu den Anfragen`,"action-href":`/verleih/anfragen`},{default:d(()=>[x.pending.length?(s(),r(`ul`,h,[(s(!0),r(e,null,c(x.pending,e=>(s(),r(`li`,{key:e.id,class:`ih:flex ih:items-center ih:gap-3 ih:px-5 ih:py-2.5`},[e.item?.thumb_url?(s(),r(`img`,{key:0,src:e.item.thumb_url,alt:``,class:`ih:size-10 ih:rounded ih:bg-muted ih:object-contain`},null,8,g)):n(``,!0),i(`div`,_,[o(u(f),{href:e.item?.url??`/verleih/anfragen`,class:`ih:block ih:truncate ih:text-sm ih:font-medium ih:hover:underline`},{default:d(()=>[a(l(e.item?.title),1)]),_:2},1032,[`href`]),i(`p`,v,l(e.user?.name)+` · nach `+l(e.location),1)]),i(`span`,y,l(u(m)(e.created_at)),1)]))),128))])):(s(),r(`p`,b,`Keine offenen Anfragen.`))]),_:1}))}};export{x as default};

12
dist/inhaus.json vendored Normal file
View file

@ -0,0 +1,12 @@
{
"components": {
"editorial/EditorialRequests": "editorial/EditorialRequests.js",
"pages/Editor": "pages/Editor.js",
"pages/Index": "pages/Index.js",
"pages/Requests": "pages/Requests.js",
"pages/Show": "pages/Show.js"
},
"css": [
"assets/style-DpnhOE_3.css"
]
}

1
dist/pages/Editor.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/pages/Index.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/pages/Requests.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/pages/Show.js vendored Normal file

File diff suppressed because one or more lines are too long

63
inhaus-sdk/theme.css Normal file
View file

@ -0,0 +1,63 @@
/*
* Automatisch erzeugt (scripts/generate-sdk-shims.mjs) – Design-Tokens des Portals.
* In der style.css eines Plugins: @import "../../inhaus-sdk/theme.css";
* Farben, Ecken und Schrift folgen so dem Erscheinungsbild der Installation.
*
* Tailwind-Klassen in Plugins tragen das Präfix „ih:“ (z. B. ih:grid, ih:lg:grid-cols-2, ih:bg-brand).
* So kann das CSS eines Plugins nie die Klassen des Portals überschreiben.
* Nur Hilfsklassen – Grundstile (Preflight) bringt das Portal selbst mit.
*/
@import "tailwindcss/theme" layer(theme) prefix(ih);
@import "tailwindcss/utilities" layer(utilities);
@custom-variant dark (&:is(.dark *));
@theme inline {
--font-sans: var(--font-body);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) * 1.5);
--radius-2xl: calc(var(--radius) * 2);
/* „Pille“: voll gerundet – außer bei „Eckig“ im Erscheinungsbild (dann 0) */
--radius-pill: calc(var(--radius) * 1000);
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
--color-brand-text: var(--brand-text);
--color-accent2: var(--accent2);
--color-accent2-foreground: var(--accent2-foreground);
--color-accent2-text: var(--accent2-text);
--color-brand-soft: var(--brand-soft);
--color-brand-soft-foreground: var(--brand-soft-foreground);
--color-brand-50: var(--brand-50);
--color-brand-100: var(--brand-100);
--color-brand-200: var(--brand-200);
--color-brand-300: var(--brand-300);
--color-brand-400: var(--brand-400);
--color-brand-500: var(--brand-500);
--color-brand-600: var(--brand-600);
--color-brand-700: var(--brand-700);
--color-brand-800: var(--brand-800);
--color-brand-900: var(--brand-900);
--color-brand-950: var(--brand-950);
}

127
inhaus-sdk/vite.js Normal file
View file

@ -0,0 +1,127 @@
/**
* Vite-Voreinstellung für Inhaus-Plugins (Plugin-SDK).
*
* // vite.config.js im Plugin
* import { defineConfig } from 'vite';
* import { inhausPlugin } from './inhaus-sdk/vite.js';
* export default defineConfig(inhausPlugin());
*
* Baut jede Vue-Datei unter resources/js/{pages,widgets,blocks,profile,profile-panels,editorial,header}/
* als eigenes ES-Modul nach dist/ und schreibt dist/inhaus.json. Vue, Inertia und @inhaus/ui
* bleiben extern – das Portal stellt sie per Import Map bereit.
*/
import { existsSync, globSync } from 'node:fs';
import { resolve } from 'node:path';
import postcss from 'postcss';
import vue from '@vitejs/plugin-vue';
import tailwindcss from '@tailwindcss/vite';
export const KINDS = ['pages', 'widgets', 'blocks', 'profile', 'profile-panels', 'editorial', 'header'];
export const EXTERNAL = ['vue', '@inertiajs/vue3', '@inhaus/ui'];
export function inhausPlugin({ root = process.cwd() } = {}) {
const input = {};
for (const kind of KINDS) {
for (const file of globSync(`resources/js/${kind}/**/*.vue`, { cwd: root })) {
const name = file.replace(`resources/js/${kind}/`, '').replace(/\.vue$/, '');
input[`${kind}/${name}`] = resolve(root, file);
}
}
if (existsSync(resolve(root, 'resources/css/style.css'))) {
input.style = resolve(root, 'resources/css/style.css');
}
if (Object.keys(input).length === 0) {
throw new Error('Keine Oberfläche gefunden: Vue-Dateien gehören nach resources/js/<pages|widgets|blocks|profile|profile-panels|editorial|header>/.');
}
return {
plugins: [vue(), tailwindcss(), manifest(Object.keys(input)), strongerVariants()],
// Plugins laufen unter /plugin-assets/<slug>/<version>/ – Pfade relativ halten
base: './',
build: {
outDir: 'dist',
emptyOutDir: true,
target: 'es2022',
rollupOptions: {
input,
external: EXTERNAL,
preserveEntrySignatures: 'strict',
output: {
format: 'es',
entryFileNames: '[name].js',
chunkFileNames: 'chunks/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
},
},
};
}
/** dist/inhaus.json: welche Komponente in welcher Datei steckt, welches CSS dazugehört */
function manifest(entries) {
return {
name: 'inhaus-manifest',
generateBundle(_, bundle) {
const components = {};
const css = [];
for (const file of Object.values(bundle)) {
if (file.type === 'chunk' && file.isEntry && entries.includes(file.name) && file.name !== 'style') {
components[file.name] = file.fileName;
}
if (file.type === 'asset' && file.fileName.endsWith('.css')) {
css.push(file.fileName);
}
}
// Leere Hülle des CSS-Einstiegs nicht ausliefern
for (const [key, file] of Object.entries(bundle)) {
if (file.type === 'chunk' && file.name === 'style') delete bundle[key];
}
this.emitFile({ type: 'asset', fileName: 'inhaus.json', source: JSON.stringify({ components, css: [...new Set(css)] }, null, 4) });
},
};
}
/**
* Mehrere Plugins bringen jeweils eigenes CSS mit, und dieselbe Hilfsklasse (z. B. ih:grid) kann in
* mehreren Dateien stehen. Lädt ein anderes Plugin sein CSS später, würde dessen „ih:grid“ sonst
* die Varianten dieses Plugins (ih:lg:hidden, ih:hover:…) überstimmen. Deshalb bekommen Regeln
* mit Variante (Media Query, :hover …) eine doppelte Klasse – sie gewinnen so immer gegen
* einfache Klassen, egal in welcher Reihenfolge die Dateien laden.
*/
export function strongerVariants() {
const pseudo = /(?<!\\):/;
const firstClass = /\.((?:\\.|[\w-])+)/;
return {
name: 'inhaus-stronger-variants',
enforce: 'post',
generateBundle(_, bundle) {
for (const file of Object.values(bundle)) {
if (file.type !== 'asset' || !file.fileName.endsWith('.css')) continue;
const root = postcss.parse(String(file.source));
root.walkRules((rule) => {
let conditional = false;
for (let parent = rule.parent; parent && parent.type !== 'root'; parent = parent.parent) {
if (parent.type === 'atrule' && parent.name !== 'layer') conditional = true;
}
rule.selectors = rule.selectors.map((selector) => (conditional || pseudo.test(selector.replace(/^[^.]*/, ''))) && firstClass.test(selector)
? selector.replace(firstClass, (match) => match + match)
: selector);
});
file.source = root.toString();
}
},
};
}

1712
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

21
package.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "inhaus-plugin-verleih",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite build --watch",
"package": "vite build && php bin/package"
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.3",
"@vitejs/plugin-vue": "^6.0.9",
"postcss": "^8.5.28",
"tailwindcss": "^4.3.3",
"vite": "^8.3.1",
"vue": "^3.5.43"
},
"dependencies": {
"@lucide/vue": "^1.48.0"
}
}

14
plugin.json Normal file
View file

@ -0,0 +1,14 @@
{
"slug": "verleih",
"name": "Verleih",
"version": "1.0.0",
"description": "Verleihsystem, z. B. für die Bilder des Künstlerteams: Übersicht mit Status und aktuellem Standort, Anfragen im Portal mit Zusage oder Absage, Import aus dem bisherigen WordPress-Verleihsystem.",
"author": "Loheide",
"namespace": "Inhaus\\Plugins\\Verleih\\",
"class": "Inhaus\\Plugins\\Verleih\\VerleihPlugin",
"requires": {
"core": ">=0.42.0",
"php": ">=8.3"
},
"update_url": "https://git.loheide.cloud/api/v1/repos/friloo/inhaus-plugin-verleih/releases/latest"
}

12
resources/css/style.css Normal file
View file

@ -0,0 +1,12 @@
/* Tailwind mit den Design-Tokens des Portals – Klassen mit Präfix „ih:“, z. B. ih:bg-brand, ih:text-muted-foreground, ih:rounded-lg */
@import "../../inhaus-sdk/theme.css";
@source "../js";
/* Beschreibung (bereinigtes HTML aus dem Editor bzw. aus WordPress) */
.verleih-text p { margin: 0.5rem 0; }
.verleih-text p:first-child { margin-top: 0; }
.verleih-text p:last-child { margin-bottom: 0; }
.verleih-text ul { list-style: disc; padding-left: 1.25rem; margin: 0.5rem 0; }
.verleih-text ol { list-style: decimal; padding-left: 1.25rem; margin: 0.5rem 0; }
.verleih-text h2, .verleih-text h3 { font-weight: 600; margin: 1rem 0 0.5rem; }
.verleih-text a { color: var(--color-brand-text); text-decoration: underline; }

View file

@ -0,0 +1,26 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { ImageOff, MapPin } from '@lucide/vue';
import StatusBadge from './StatusBadge.vue';
defineProps({
item: { type: Object, required: true },
});
</script>
<template>
<article class="ih:group ih:flex ih:flex-col ih:overflow-hidden ih:rounded-lg ih:border ih:bg-card ih:shadow-xs ih:transition-shadow ih:hover:shadow-md">
<!-- Kunstwerke nicht beschneiden: ganzes Bild auf ruhigem Grund -->
<Link :href="item.url" prefetch class="ih:relative ih:grid ih:aspect-[4/3] ih:place-items-center ih:overflow-hidden ih:bg-muted ih:p-3">
<img v-if="item.thumb_url" :src="item.thumb_url" :alt="item.title" loading="lazy" class="ih:max-h-full ih:max-w-full ih:object-contain ih:shadow-sm ih:transition-transform ih:duration-300 ih:group-hover:scale-[1.02]" />
<ImageOff v-else class="ih:size-8 ih:text-muted-foreground" :stroke-width="1.5" />
<StatusBadge :lent="item.lent" class="ih:absolute ih:top-2 ih:left-2" />
</Link>
<div class="ih:flex ih:flex-1 ih:flex-col ih:gap-1 ih:p-3">
<Link :href="item.url" prefetch class="ih:line-clamp-2 ih:text-[15px] ih:leading-snug ih:font-semibold ih:hover:underline">{{ item.title }}</Link>
<p v-if="item.location" class="ih:mt-auto ih:flex ih:items-center ih:gap-1 ih:pt-1 ih:text-xs ih:text-muted-foreground">
<MapPin class="ih:size-3.5 ih:shrink-0" /><span class="ih:truncate">{{ item.location }}</span>
</p>
</div>
</article>
</template>

View file

@ -0,0 +1,62 @@
<script setup>
import { useForm } from '@inertiajs/vue3';
import { LoaderCircle, Send } from '@lucide/vue';
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FormField, Input, Textarea } from '@inhaus/ui';
const props = defineProps({
item: { type: Object, required: true },
labels: { type: Object, required: true },
defaultLocation: { type: String, default: null },
});
const open = defineModel('open', { type: Boolean, default: false });
const today = new Date().toISOString().slice(0, 10);
const form = useForm({ location: props.defaultLocation ?? '', from: '', until: '', message: '' });
function submit() {
form.post(`/verleih/${props.item.id}/anfragen`, {
preserveScroll: true,
onSuccess: () => {
open.value = false;
form.reset('from', 'until', 'message');
},
});
}
</script>
<template>
<Dialog v-model:open="open">
<DialogContent class="ih:sm:max-w-lg">
<DialogHeader>
<DialogTitle>„{{ item.title }}“ anfragen</DialogTitle>
<DialogDescription>
Das Team bekommt Ihre Anfrage im Portal und per E-Mail und meldet sich bei Ihnen.
<template v-if="item.lent"> Gerade ist es verliehen – Sie können es trotzdem für später anfragen.</template>
</DialogDescription>
</DialogHeader>
<form id="verleih-anfrage" class="ih:grid ih:gap-4" @submit.prevent="submit">
<FormField id="vl-location" label="Wo soll es hin?" :error="form.errors.location">
<Input id="vl-location" v-model="form.location" maxlength="200" placeholder="z. B. Verwaltung, Besprechungsraum 2. OG" required />
</FormField>
<div class="ih:grid ih:gap-4 ih:sm:grid-cols-2">
<FormField id="vl-from" label="Ab (optional)" :error="form.errors.from">
<Input id="vl-from" v-model="form.from" type="date" :min="today" />
</FormField>
<FormField id="vl-until" label="Bis (optional)" :error="form.errors.until">
<Input id="vl-until" v-model="form.until" type="date" :min="form.from || today" />
</FormField>
</div>
<FormField id="vl-message" label="Nachricht (optional)" :error="form.errors.message">
<Textarea id="vl-message" v-model="form.message" rows="3" maxlength="2000" placeholder="z. B. Anlass, Ansprechperson vor Ort …" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="open = false">Abbrechen</Button>
<Button type="submit" form="verleih-anfrage" :disabled="form.processing || !form.location.trim()">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /><Send v-else /> Anfrage senden
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>

View file

@ -0,0 +1,15 @@
<script setup>
defineProps({
lent: { type: Boolean, required: true },
});
</script>
<template>
<span
class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:px-2 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:shadow-xs"
:class="lent ? 'ih:bg-card ih:text-muted-foreground' : 'ih:bg-brand ih:text-brand-foreground'"
>
<span class="ih:size-1.5 ih:rounded-full" :class="lent ? 'ih:bg-muted-foreground' : 'ih:bg-brand-foreground'" aria-hidden="true" />
{{ lent ? 'Verliehen' : 'Verfügbar' }}
</span>
</template>

View file

@ -0,0 +1,22 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Panel, formatRelative } from '@inhaus/ui';
defineProps({ pending: { type: Array, required: true } });
</script>
<template>
<Panel title="Verleih – offene Anfragen" action-label="Zu den Anfragen" action-href="/verleih/anfragen">
<ul v-if="pending.length" class="ih:-mx-5 ih:divide-y ih:border-t">
<li v-for="r in pending" :key="r.id" class="ih:flex ih:items-center ih:gap-3 ih:px-5 ih:py-2.5">
<img v-if="r.item?.thumb_url" :src="r.item.thumb_url" alt="" class="ih:size-10 ih:rounded ih:bg-muted ih:object-contain" />
<div class="ih:min-w-0 ih:flex-1">
<Link :href="r.item?.url ?? '/verleih/anfragen'" class="ih:block ih:truncate ih:text-sm ih:font-medium ih:hover:underline">{{ r.item?.title }}</Link>
<p class="ih:truncate ih:text-xs ih:text-muted-foreground">{{ r.user?.name }} · nach {{ r.location }}</p>
</div>
<span class="ih:shrink-0 ih:text-xs ih:text-muted-foreground">{{ formatRelative(r.created_at) }}</span>
</li>
</ul>
<p v-else class="ih:text-sm ih:text-muted-foreground">Keine offenen Anfragen.</p>
</Panel>
</template>

View file

@ -0,0 +1,123 @@
<script setup>
import { computed, ref } from 'vue';
import { Link, useForm } from '@inertiajs/vue3';
import { ChevronLeft, ImagePlus, LoaderCircle, Trash2 } from '@lucide/vue';
import { AppLayout, Button, FormField, Input, PageHeader, Panel, RichTextEditor } from '@inhaus/ui';
const props = defineProps({
item: { type: Object, default: null },
labels: { type: Object, required: true },
});
const it = props.item;
const form = useForm({
title: it?.title ?? '',
description: it?.description ?? '',
lent: it?.lent ?? false,
location: it?.location ?? '',
image: null,
remove_image: false,
});
const preview = ref(it?.image_url ?? null);
const fileInput = ref(null);
const dragging = ref(false);
function choose(files) {
const file = [...files].find((f) => f.type.startsWith('image/'));
if (!file) return;
form.image = file;
form.remove_image = false;
preview.value = URL.createObjectURL(file);
}
function removeImage() {
form.image = null;
form.remove_image = true;
preview.value = null;
}
const title = computed(() => (it ? `${props.labels.singular} bearbeiten` : `${props.labels.singular} erfassen`));
function submit() {
form.transform((data) => ({ ...data, lent: data.lent ? 1 : 0, remove_image: data.remove_image ? 1 : 0 }))
.post(it ? `/verleih/${it.id}` : '/verleih', { forceFormData: true });
}
</script>
<template>
<AppLayout :title="title">
<Link :href="it ? it.url : '/verleih'" class="ih:mb-4 ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground">
<ChevronLeft class="ih:size-4" /> {{ it ? it.title : labels.title }}
</Link>
<PageHeader :title="title" />
<form class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_20rem]" @submit.prevent="submit">
<div class="ih:grid ih:min-w-0 ih:content-start ih:gap-6">
<Panel>
<div class="ih:grid ih:gap-5">
<FormField id="vl-title" label="Titel" :error="form.errors.title">
<Input id="vl-title" v-model="form.title" maxlength="200" required placeholder="z. B. „Sommerwiese“, Acryl auf Leinwand" />
</FormField>
<FormField id="vl-description" label="Beschreibung" :error="form.errors.description" hint="Z. B. Künstlerin oder Künstler, Maße, Technik – alles, was bei der Auswahl hilft.">
<RichTextEditor id="vl-description" v-model="form.description" bordered min-height="12rem" :headings="[2, 3]" placeholder="Beschreibung …" />
</FormField>
</div>
</Panel>
</div>
<aside class="ih:grid ih:content-start ih:gap-6">
<Panel>
<div class="ih:grid ih:gap-3">
<p class="ih:text-[13px] ih:font-medium">Foto</p>
<div
class="ih:relative ih:grid ih:aspect-[4/3] ih:place-items-center ih:overflow-hidden ih:rounded-md ih:border ih:border-dashed ih:bg-muted ih:p-2"
:class="dragging ? 'ih:border-brand ih:bg-brand-soft' : ''"
@dragover.prevent="dragging = true"
@dragleave="dragging = false"
@drop.prevent="dragging = false; choose($event.dataTransfer.files)"
>
<img v-if="preview" :src="preview" alt="Vorschau" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<button v-else type="button" class="ih:grid ih:justify-items-center ih:gap-1 ih:text-sm ih:text-muted-foreground" @click="fileInput.click()">
<ImagePlus class="ih:size-8" :stroke-width="1.5" /> Foto wählen oder hierher ziehen
</button>
</div>
<input ref="fileInput" type="file" accept="image/jpeg,image/png,image/webp" class="ih:hidden" @change="choose($event.target.files)" />
<div v-if="preview" class="ih:flex ih:gap-2">
<Button type="button" variant="outline" size="sm" @click="fileInput.click()"><ImagePlus /> Anderes Foto</Button>
<Button type="button" variant="ghost" size="sm" class="ih:text-destructive" @click="removeImage"><Trash2 /> Entfernen</Button>
</div>
<p v-if="form.errors.image" class="ih:text-[13px] ih:text-destructive">{{ form.errors.image }}</p>
<p v-if="form.progress" class="ih:text-[13px] ih:text-muted-foreground">Wird hochgeladen … {{ form.progress.percentage }} %</p>
</div>
</Panel>
<Panel>
<fieldset class="ih:grid ih:gap-4">
<legend class="ih:mb-2 ih:text-[13px] ih:font-medium">Verleihstatus</legend>
<div class="ih:grid ih:grid-cols-2 ih:gap-1 ih:rounded-md ih:bg-muted ih:p-1" role="radiogroup" aria-label="Verleihstatus">
<button
v-for="option in [{ value: false, label: 'Verfügbar' }, { value: true, label: 'Verliehen' }]"
:key="option.label"
type="button"
role="radio"
:aria-checked="form.lent === option.value"
class="ih:rounded ih:py-1.5 ih:text-sm ih:font-medium"
:class="form.lent === option.value ? 'ih:bg-card ih:shadow-xs' : 'ih:text-muted-foreground'"
@click="form.lent = option.value"
>{{ option.label }}</button>
</div>
<FormField id="vl-location" :label="form.lent ? 'Verliehen an / Ort' : 'Aktueller Standort'" :error="form.errors.location">
<Input id="vl-location" v-model="form.location" maxlength="200" :placeholder="form.lent ? 'z. B. Verwaltung, Flur 1. OG' : 'z. B. Lager Künstlerteam'" />
</FormField>
</fieldset>
</Panel>
<Button type="submit" size="lg" :disabled="form.processing || !form.title.trim()">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /> Speichern
</Button>
</aside>
</form>
</AppLayout>
</template>

View file

@ -0,0 +1,114 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Images, Inbox, Plus, Search, Settings2 } from '@lucide/vue';
import { AppLayout, Button, EmptyState, PageHeader, formatDate, toast } from '@inhaus/ui';
import ItemCard from '../components/ItemCard.vue';
const props = defineProps({
items: { type: Array, required: true },
filters: { type: Object, required: true },
counts: { type: Object, required: true },
labels: { type: Object, required: true },
canManage: { type: Boolean, default: false },
pendingRequests: { type: Number, default: null },
myRequests: { type: Array, default: () => [] },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const query = ref(props.filters.q);
let timer;
watch(query, (value) => {
clearTimeout(timer);
timer = setTimeout(() => apply({ q: value }), 300);
});
function apply(changes) {
const params = { ...props.filters, ...changes };
router.get('/verleih', Object.fromEntries(Object.entries(params).filter(([, v]) => v)), { preserveState: true, preserveScroll: true, replace: true });
}
const tabs = [
{ value: null, label: 'Alle', count: 'all' },
{ value: 'verfuegbar', label: 'Verfügbar', count: 'available' },
{ value: 'verliehen', label: 'Verliehen', count: 'lent' },
];
const cancel = (request) => window.confirm('Anfrage zurückziehen?') && router.delete(`/verleih/anfragen/${request.id}`, { preserveScroll: true });
</script>
<template>
<AppLayout :title="labels.title">
<PageHeader :title="labels.title" :description="`Alle ${labels.plural} auf einen Blick – verfügbar oder verliehen, und wo sie gerade sind.`">
<template #actions>
<template v-if="canManage">
<Button variant="outline" as-child>
<Link href="/verleih/anfragen"><Inbox /> Anfragen<span v-if="pendingRequests" class="ih:rounded-full ih:bg-brand ih:px-1.5 ih:text-[11px] ih:text-brand-foreground">{{ pendingRequests }}</span></Link>
</Button>
<Button as-child><Link href="/verleih/neu"><Plus /> {{ labels.singular }} erfassen</Link></Button>
</template>
</template>
</PageHeader>
<!-- Eigene Anfragen -->
<section v-if="myRequests.length" class="ih:mb-6 ih:rounded-lg ih:border ih:bg-card ih:p-4" aria-labelledby="meine-anfragen">
<h2 id="meine-anfragen" class="ih:mb-2 ih:text-sm ih:font-semibold">Ihre Anfragen</h2>
<ul class="ih:divide-y">
<li v-for="request in myRequests" :key="request.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:py-2 ih:text-sm">
<Link :href="request.item.url" class="ih:font-medium ih:hover:underline">{{ request.item.title }}</Link>
<span class="ih:text-muted-foreground">nach {{ request.location }}</span>
<span
class="ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium"
:class="request.status === 'accepted' ? 'ih:bg-brand ih:text-brand-foreground' : request.status === 'pending' ? 'ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-muted ih:text-muted-foreground'"
>{{ request.status_label }}</span>
<span v-if="request.note" class="ih:text-muted-foreground">„{{ request.note }}“</span>
<span class="ih:ml-auto ih:text-xs ih:text-muted-foreground">{{ formatDate(request.created_at) }}</span>
<button v-if="request.status === 'pending'" type="button" class="ih:text-xs ih:font-medium ih:text-muted-foreground ih:hover:text-destructive" @click="cancel(request)">Zurückziehen</button>
</li>
</ul>
</section>
<div class="ih:mb-5 ih:flex ih:flex-wrap ih:items-center ih:gap-3">
<nav class="ih:flex ih:flex-wrap ih:gap-1.5" aria-label="Status">
<button
v-for="tab in tabs"
:key="tab.label"
type="button"
class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:border ih:px-3 ih:py-1 ih:text-[13px]"
:class="filters.status === tab.value ? 'ih:border-brand ih:bg-brand ih:text-brand-foreground' : 'ih:bg-card ih:hover:bg-accent'"
:aria-pressed="filters.status === tab.value"
@click="apply({ status: tab.value })"
>
{{ tab.label }} <span class="ih:tabular-nums ih:opacity-75">{{ counts[tab.count] }}</span>
</button>
</nav>
<div class="ih:relative ih:ml-auto ih:w-full ih:sm:w-64">
<Search class="ih:pointer-events-none ih:absolute ih:top-1/2 ih:left-2.5 ih:size-4 ih:-translate-y-1/2 ih:text-muted-foreground" />
<input
v-model="query"
type="search"
:placeholder="`${labels.plural} oder Orte suchen`"
:aria-label="`${labels.plural} durchsuchen`"
class="ih:h-9 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:pr-3 ih:pl-8 ih:text-sm ih:shadow-xs ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none"
/>
</div>
</div>
<div v-if="items.length" class="ih:grid ih:grid-cols-2 ih:gap-3 ih:sm:gap-4 ih:md:grid-cols-3 ih:xl:grid-cols-4">
<ItemCard v-for="item in items" :key="item.id" :item="item" />
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
<EmptyState
:icon="Images"
:title="filters.q || filters.status ? `Keine passenden ${labels.plural}` : `Noch keine ${labels.plural}`"
:text="canManage && !filters.q && !filters.status ? `Legen Sie mit „${labels.singular} erfassen“ los – oder übernehmen Sie den Bestand aus WordPress (Administration → Portal → Verleih).` : ''"
/>
</div>
<p v-if="canManage" class="ih:mt-6 ih:flex ih:items-center ih:gap-1.5 ih:text-xs ih:text-muted-foreground">
<Settings2 class="ih:size-3.5" /> Bezeichnungen und Übernahme aus WordPress: Administration → Portal → Verleih
</p>
</AppLayout>
</template>

View file

@ -0,0 +1,128 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, useForm, usePage } from '@inertiajs/vue3';
import { CalendarDays, Check, ChevronLeft, ImageOff, Inbox, LoaderCircle, MapPin, MessageSquareText, X } from '@lucide/vue';
import {
AppLayout,
Button,
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
EmptyState,
FormField,
PageHeader,
PersonAvatar,
Textarea,
formatDate,
formatRelative,
toast,
} from '@inhaus/ui';
import StatusBadge from '../components/StatusBadge.vue';
defineProps({
pending: { type: Array, required: true },
recent: { type: Array, default: () => [] },
labels: { type: Object, required: true },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
// Zusagen / Absagen mit optionalem Hinweis
const deciding = ref(null); // { request, accept }
const form = useForm({ note: '' });
function open(request, accept) {
form.reset();
form.clearErrors();
deciding.value = { request, accept };
}
function submit() {
const { request, accept } = deciding.value;
form.post(`/verleih/anfragen/${request.id}/${accept ? 'zusagen' : 'absagen'}`, { preserveScroll: true, onSuccess: () => (deciding.value = null) });
}
const period = (r) => [r.from ? `ab ${formatDate(r.from)}` : null, r.until ? `bis ${formatDate(r.until)}` : null].filter(Boolean).join(' ');
</script>
<template>
<AppLayout title="Anfragen">
<Link href="/verleih" class="ih:mb-4 ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> {{ labels.title }}</Link>
<PageHeader title="Anfragen" :description="`Zusagen trägt das ${labels.singular} gleich als verliehen ein – mit Wunschort und Person. Die anfragende Person wird benachrichtigt.`" />
<section aria-labelledby="offen" class="ih:mb-8">
<h2 id="offen" class="ih:mb-3 ih:text-sm ih:font-semibold">Offen <span class="ih:text-muted-foreground">({{ pending.length }})</span></h2>
<div v-if="pending.length" class="ih:grid ih:gap-3">
<article v-for="request in pending" :key="request.id" class="ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-4 ih:sm:grid-cols-[7rem_minmax(0,1fr)_auto] ih:sm:items-center">
<Link :href="request.item?.url ?? '#'" class="ih:grid ih:aspect-[4/3] ih:w-28 ih:place-items-center ih:overflow-hidden ih:rounded-md ih:bg-muted">
<img v-if="request.item?.thumb_url" :src="request.item.thumb_url" :alt="request.item.title" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<ImageOff v-else class="ih:size-6 ih:text-muted-foreground" />
</Link>
<div class="ih:grid ih:min-w-0 ih:gap-1.5">
<div class="ih:flex ih:flex-wrap ih:items-center ih:gap-2">
<Link :href="request.item?.url ?? '#'" class="ih:font-semibold ih:hover:underline">{{ request.item?.title }}</Link>
<StatusBadge v-if="request.item" :lent="request.item.lent" class="ih:border" />
</div>
<p class="ih:flex ih:items-center ih:gap-2 ih:text-sm">
<PersonAvatar :person="request.user" class="ih:size-6" />
<span><span class="ih:font-medium">{{ request.user?.name }}</span><span v-if="request.user?.department" class="ih:text-muted-foreground"> · {{ request.user.department }}</span></span>
<span class="ih:text-xs ih:text-muted-foreground">{{ formatRelative(request.created_at) }}</span>
</p>
<p class="ih:flex ih:flex-wrap ih:gap-x-4 ih:gap-y-1 ih:text-sm ih:text-muted-foreground">
<span class="ih:inline-flex ih:items-center ih:gap-1"><MapPin class="ih:size-3.5" /> {{ request.location }}</span>
<span v-if="period(request)" class="ih:inline-flex ih:items-center ih:gap-1"><CalendarDays class="ih:size-3.5" /> {{ period(request) }}</span>
</p>
<p v-if="request.message" class="ih:flex ih:gap-1.5 ih:text-sm"><MessageSquareText class="ih:mt-0.5 ih:size-3.5 ih:shrink-0 ih:text-muted-foreground" /> „{{ request.message }}“</p>
<p v-if="request.item?.lent" class="ih:text-xs ih:text-muted-foreground">Gerade verliehen{{ request.item.location ? ` (${request.item.location})` : '' }} – eine Zusage trägt den neuen Ort ein.</p>
</div>
<div class="ih:flex ih:gap-2 ih:sm:flex-col">
<Button @click="open(request, true)"><Check /> Zusagen</Button>
<Button variant="outline" @click="open(request, false)"><X /> Absagen</Button>
</div>
</article>
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
<EmptyState :icon="Inbox" title="Keine offenen Anfragen" text="Neue Anfragen kommen im Portal und per E-Mail." />
</div>
</section>
<section v-if="recent.length" aria-labelledby="zuletzt">
<h2 id="zuletzt" class="ih:mb-3 ih:text-sm ih:font-semibold">Zuletzt beantwortet</h2>
<ul class="ih:divide-y ih:rounded-lg ih:border ih:bg-card">
<li v-for="request in recent" :key="request.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:px-4 ih:py-2.5 ih:text-sm">
<Link :href="request.item?.url ?? '#'" class="ih:font-medium ih:hover:underline">{{ request.item?.title }}</Link>
<span class="ih:text-muted-foreground">{{ request.user?.name }} · {{ request.location }}</span>
<span class="ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium" :class="request.status === 'accepted' ? 'ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-muted ih:text-muted-foreground'">{{ request.status_label }}</span>
<span class="ih:ml-auto ih:text-xs ih:text-muted-foreground">{{ request.decider ? `${request.decider.name}, ` : '' }}{{ formatDate(request.decided_at ?? request.created_at) }}</span>
</li>
</ul>
</section>
<Dialog :open="!!deciding" @update:open="(v) => !v && (deciding = null)">
<DialogContent v-if="deciding" class="ih:sm:max-w-md">
<DialogHeader>
<DialogTitle>{{ deciding.accept ? 'Zusagen' : 'Absagen' }}: {{ deciding.request.item?.title }}</DialogTitle>
<DialogDescription>
<template v-if="deciding.accept">Wird als verliehen an {{ deciding.request.user?.name }} nach „{{ deciding.request.location }}“ eingetragen.</template>
<template v-else>{{ deciding.request.user?.name }} bekommt die Absage im Portal und per E-Mail.</template>
</DialogDescription>
</DialogHeader>
<form id="verleih-entscheidung" @submit.prevent="submit">
<FormField id="vl-note" label="Hinweis (optional)" :error="form.errors.note || form.errors.status">
<Textarea id="vl-note" v-model="form.note" rows="3" maxlength="1000" :placeholder="deciding.accept ? 'z. B. Wir bringen es am Montag vorbei.' : 'z. B. Ist bis Ende März schon vergeben.'" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="deciding = null">Abbrechen</Button>
<Button type="submit" form="verleih-entscheidung" :variant="deciding.accept ? 'default' : 'destructive'" :disabled="form.processing">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /> {{ deciding.accept ? 'Zusagen' : 'Absagen' }}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</AppLayout>
</template>

149
resources/js/pages/Show.vue Normal file
View file

@ -0,0 +1,149 @@
<script setup>
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
import { CalendarDays, ChevronLeft, Clock, ImageOff, LoaderCircle, MapPin, PencilLine, Send, Trash2, Undo2, UserRound, X } from '@lucide/vue';
import { AppLayout, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FormField, Input, PersonAvatar, formatDate, toast } from '@inhaus/ui';
import RequestDialog from '../components/RequestDialog.vue';
import StatusBadge from '../components/StatusBadge.vue';
const props = defineProps({
item: { type: Object, required: true },
labels: { type: Object, required: true },
canManage: { type: Boolean, default: false },
myRequest: { type: Object, default: null },
defaultLocation: { type: String, default: null },
requests: { type: Array, default: () => [] },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const item = computed(() => props.item);
const requesting = ref(false);
const zoom = ref(false);
const onKey = (event) => event.key === 'Escape' && (zoom.value = false);
watch(zoom, (open) => (open ? window.addEventListener('keydown', onKey) : window.removeEventListener('keydown', onKey)));
onBeforeUnmount(() => window.removeEventListener('keydown', onKey));
// Team: zurücknehmen mit neuem Standort
const returning = ref(false);
const giveBack = useForm({ location: '' });
const submitReturn = () => giveBack.post(`/verleih/${item.value.id}/zurueck`, { preserveScroll: true, onSuccess: () => (returning.value = false) });
const cancel = () => window.confirm('Anfrage zurückziehen?') && router.delete(`/verleih/anfragen/${props.myRequest.id}`, { preserveScroll: true });
const remove = () => window.confirm(`„${item.value.title}“ endgültig löschen?`) && router.delete(`/verleih/${item.value.id}`);
const period = (from, until) =>
[from ? `ab ${formatDate(from)}` : null, until ? `bis ${formatDate(until)}` : null].filter(Boolean).join(' ');
</script>
<template>
<AppLayout :title="item.title">
<div class="ih:mb-4 ih:flex ih:flex-wrap ih:items-center ih:justify-between ih:gap-3">
<Link href="/verleih" class="ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> {{ labels.title }}</Link>
<div v-if="canManage" class="ih:flex ih:gap-2">
<Button variant="outline" size="sm" as-child><Link :href="`/verleih/${item.id}/bearbeiten`"><PencilLine /> Bearbeiten</Link></Button>
<Button variant="ghost" size="sm" class="ih:text-destructive ih:hover:text-destructive" @click="remove"><Trash2 /> Löschen</Button>
</div>
</div>
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_22rem]">
<!-- Bild: ganz, ohne Zuschnitt -->
<div class="ih:grid ih:min-w-0 ih:content-start ih:gap-6">
<button
v-if="item.image_url"
type="button"
class="ih:grid ih:place-items-center ih:rounded-lg ih:border ih:bg-muted ih:p-4 ih:sm:p-8"
:aria-label="`${item.title} vergrößern`"
@click="zoom = true"
>
<img :src="item.image_url" :alt="item.title" class="ih:max-h-[70vh] ih:w-auto ih:max-w-full ih:object-contain ih:shadow-md" />
</button>
<div v-else class="ih:grid ih:aspect-[4/3] ih:place-items-center ih:rounded-lg ih:border ih:bg-muted ih:text-muted-foreground">
<ImageOff class="ih:size-10" :stroke-width="1.5" />
</div>
<section v-if="item.description" class="ih:rounded-lg ih:border ih:bg-card ih:p-5">
<!-- serverseitig bereinigtes HTML -->
<div class="verleih-text ih:text-[15px] ih:leading-relaxed" v-html="item.description" />
</section>
</div>
<aside class="ih:grid ih:content-start ih:gap-4 ih:lg:sticky ih:lg:top-24">
<section class="ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-5">
<div class="ih:grid ih:gap-2">
<StatusBadge :lent="item.lent" class="ih:w-fit ih:border" />
<h1 class="ih:text-xl ih:leading-snug ih:font-semibold">{{ item.title }}</h1>
</div>
<dl class="ih:grid ih:gap-2 ih:text-sm">
<div class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Aktueller Standort</dt>
<MapPin class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd>{{ item.location || 'Standort nicht angegeben' }}</dd>
</div>
<div v-if="item.lent && (item.lent_since || item.lent_until)" class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Zeitraum</dt>
<CalendarDays class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd>Verliehen {{ period(item.lent_since, item.lent_until) }}</dd>
</div>
<div v-if="item.lent_to" class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Ausgeliehen von</dt>
<UserRound class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd><Link :href="`/personen/${item.lent_to.id}`" class="ih:hover:underline">{{ item.lent_to.name }}</Link></dd>
</div>
</dl>
<div v-if="myRequest" class="ih:grid ih:gap-2 ih:rounded-md ih:bg-brand-soft ih:p-3 ih:text-sm ih:text-brand-text">
<p class="ih:flex ih:items-center ih:gap-1.5 ih:font-medium"><Clock class="ih:size-4" /> Angefragt am {{ formatDate(myRequest.created_at) }}</p>
<p>Nach „{{ myRequest.location }}“ {{ period(myRequest.from, myRequest.until) }} – das Team meldet sich.</p>
<button type="button" class="ih:w-fit ih:text-xs ih:font-medium ih:underline" @click="cancel">Anfrage zurückziehen</button>
</div>
<Button v-else size="lg" class="ih:w-full" @click="requesting = true"><Send /> {{ labels.singular }} anfragen</Button>
<Button v-if="canManage && item.lent" variant="outline" class="ih:w-full" @click="returning = true"><Undo2 /> Zurückgenommen</Button>
</section>
<!-- Team: Anfragen zu diesem Objekt -->
<section v-if="canManage && requests.length" class="ih:rounded-lg ih:border ih:bg-card ih:p-5">
<h2 class="ih:mb-3 ih:text-sm ih:font-semibold">Anfragen</h2>
<ul class="ih:grid ih:gap-3">
<li v-for="request in requests" :key="request.id" class="ih:flex ih:gap-3 ih:text-sm">
<PersonAvatar :person="request.user" class="ih:size-8" />
<div class="ih:min-w-0">
<p><span class="ih:font-medium">{{ request.user?.name }}</span> · {{ request.location }}</p>
<p class="ih:text-xs ih:text-muted-foreground">{{ request.status_label }} · {{ formatDate(request.created_at) }}</p>
</div>
</li>
</ul>
<Link href="/verleih/anfragen" class="ih:mt-3 ih:inline-block ih:text-sm ih:font-medium ih:text-brand-text ih:hover:underline">Alle Anfragen</Link>
</section>
</aside>
</div>
<RequestDialog v-model:open="requesting" :item="item" :labels="labels" :default-location="defaultLocation" />
<Dialog v-model:open="returning">
<DialogContent class="ih:sm:max-w-md">
<DialogHeader>
<DialogTitle>„{{ item.title }}“ zurückgenommen</DialogTitle>
<DialogDescription>Danach ist es wieder verfügbar. Wo ist es jetzt?</DialogDescription>
</DialogHeader>
<form id="verleih-zurueck" @submit.prevent="submitReturn">
<FormField id="vl-return" label="Neuer Standort" :error="giveBack.errors.location">
<Input id="vl-return" v-model="giveBack.location" maxlength="200" placeholder="z. B. Lager Künstlerteam" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="returning = false">Abbrechen</Button>
<Button type="submit" form="verleih-zurueck" :disabled="giveBack.processing"><LoaderCircle v-if="giveBack.processing" class="ih:animate-spin" /> Speichern</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<!-- Vergrößerung -->
<div v-if="zoom" class="ih:fixed ih:inset-0 ih:z-50 ih:grid ih:place-items-center ih:bg-black/85 ih:p-4" role="dialog" aria-modal="true" :aria-label="item.title" @click="zoom = false">
<img :src="item.image_url" :alt="item.title" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<button type="button" class="ih:absolute ih:top-4 ih:right-4 ih:grid ih:size-10 ih:place-items-center ih:rounded-full ih:bg-white/15 ih:text-white" aria-label="Schließen" @click.stop="zoom = false"><X /></button>
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,19 @@
<!doctype html>
<html lang="de">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>{{ $mailSubject }}</title></head>
<body style="margin:0;background:#f4f5f7;font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1a1d21">
<div style="max-width:600px;margin:0 auto;padding:24px">
<p style="margin:0 0 16px;font-size:15px;font-weight:700;color:{{ $color }}">{{ $portalName }} · {{ $area }}</p>
<div style="background:#fff;border:1px solid #e3e5e8;border-radius:8px;padding:24px">
<h1 style="margin:0 0 16px;font-size:18px">{{ $heading }}</h1>
@foreach ($lines as $line)
<p style="margin:0 0 8px;font-size:15px;line-height:1.5">{{ $line }}</p>
@endforeach
<p style="margin:20px 0 0"><a href="{{ $action[1] }}" style="display:inline-block;background:{{ $color }};color:#fff;text-decoration:none;font-weight:600;font-size:14px;padding:10px 18px;border-radius:6px">{{ $action[0] }}</a></p>
</div>
@if ($replyPerson)
<p style="margin:12px 0 0;font-size:12px;color:#5f6670">Antworten auf diese E-Mail gehen direkt an {{ $replyPerson->name }}.</p>
@endif
</div>
</body>
</html>

23
routes/web.php Normal file
View file

@ -0,0 +1,23 @@
<?php
use Illuminate\Support\Facades\Route;
use Inhaus\Plugins\Verleih\Http\Controllers\ItemController;
use Inhaus\Plugins\Verleih\Http\Controllers\RequestController;
Route::middleware('auth')->prefix('verleih')->name('verleih.')->group(function () {
Route::get('/', [ItemController::class, 'index'])->name('index');
Route::get('/neu', [ItemController::class, 'create'])->name('create');
Route::post('/', [ItemController::class, 'store'])->name('store');
Route::get('/anfragen', [RequestController::class, 'index'])->name('requests');
Route::post('/anfragen/{loanRequest}/zusagen', [RequestController::class, 'accept'])->name('requests.accept');
Route::post('/anfragen/{loanRequest}/absagen', [RequestController::class, 'decline'])->name('requests.decline');
Route::delete('/anfragen/{loanRequest}', [RequestController::class, 'cancel'])->name('requests.cancel');
Route::get('/bilder/{item}/{size}', [ItemController::class, 'image'])->whereIn('size', ['thumb', 'full'])->name('image');
Route::get('/{item}', [ItemController::class, 'show'])->whereNumber('item')->name('show');
Route::get('/{item}/bearbeiten', [ItemController::class, 'edit'])->whereNumber('item')->name('edit');
Route::post('/{item}', [ItemController::class, 'update'])->whereNumber('item')->name('update'); // POST wegen Foto-Upload
Route::delete('/{item}', [ItemController::class, 'destroy'])->whereNumber('item')->name('destroy');
Route::post('/{item}/anfragen', [RequestController::class, 'store'])->whereNumber('item')->middleware('throttle:10,60')->name('request');
Route::post('/{item}/zurueck', [ItemController::class, 'giveBack'])->whereNumber('item')->name('return');
});

View file

@ -0,0 +1,135 @@
<?php
namespace Inhaus\Plugins\Verleih\Filament\Pages;
use App\Support\Audit;
use App\Support\Settings;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Text;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Illuminate\Support\Facades\Storage;
use Inhaus\Plugins\Verleih\Labels;
use Inhaus\Plugins\Verleih\Lending;
use Inhaus\Plugins\Verleih\WordpressImport;
use Throwable;
use UnitEnum;
/**
* Verleih: Bezeichnungen und Übernahme aus dem bisherigen WordPress-Verleihsystem.
*/
class VerleihSettings extends Page
{
protected string $view = 'filament.pages.settings-form';
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPhoto;
protected static string|UnitEnum|null $navigationGroup = 'Portal';
protected static ?int $navigationSort = 45;
protected static ?string $navigationLabel = 'Verleih';
protected static ?string $title = 'Verleih';
protected static ?string $slug = 'verleih';
/** @var array<string, mixed>|null */
public ?array $data = [];
public static function canAccess(): bool
{
return auth()->user()?->can(Lending::ABILITY) ?? false;
}
public function mount(): void
{
$this->form->fill(Labels::all());
}
public function form(Schema $schema): Schema
{
return $schema->components([
Section::make('Bezeichnungen')->columns(3)->schema([
Text::make('So heißt der Bereich im Menü und auf den Seiten. Wer ihn für etwas anderes als Bilder nutzt, passt die Wörter hier an (z. B. „Geräteverleih“, „Gerät“, „Geräte“).')->columnSpanFull(),
TextInput::make('title')->label('Name des Bereichs')->required()->maxLength(40)->placeholder(Labels::DEFAULT_TITLE),
TextInput::make('singular')->label('Ein Objekt heißt')->required()->maxLength(30)->placeholder(Labels::DEFAULT_SINGULAR),
TextInput::make('plural')->label('Mehrere heißen')->required()->maxLength(30)->placeholder(Labels::DEFAULT_PLURAL),
]),
Section::make('Wer verwaltet?')->schema([
Text::make('Objekte pflegen und Anfragen beantworten darf, wer das Recht „Verleih verwalten“ hat – z. B. die Rolle „Künstlerteam“ (unter Benutzer & Rechte → Rollen). Neue Anfragen gehen an alle mit diesem Recht, im Portal und per E-Mail.'),
]),
])->statePath('data');
}
public function save(Settings $settings): void
{
$s = $this->form->getState();
$settings->setMany(['verleih.title' => trim($s['title']), 'verleih.singular' => trim($s['singular']), 'verleih.plural' => trim($s['plural'])]);
Notification::make()->success()->title('Gespeichert')->body('Der neue Name erscheint im Menü beim nächsten Seitenaufruf.')->send();
}
protected function getHeaderActions(): array
{
$import = app(WordpressImport::class);
return [
Action::make('import')->label('Aus WordPress übernehmen')->icon(Heroicon::OutlinedArrowUpTray)->color('gray')
->modalHeading('Aus dem WordPress-Verleihsystem übernehmen')
->modalDescription('In WordPress unter „Werkzeuge → Daten exportieren“ die „Objekte“ exportieren und die Datei hier hochladen. Übernommen werden Titel, Beschreibung, Bild, „verliehen“ und Verleihort. Schon übernommene Objekte bleiben unverändert.')
->schema([
FileUpload::make('file')->label('Exportdatei (.xml)')->disk('local')->directory('verleih-import')
->acceptedFileTypes(['application/xml', 'text/xml', 'application/rss+xml'])->maxSize(50 * 1024)->required(),
])
->action(function (array $data) use ($import) {
try {
$result = $import->import(Storage::disk('local')->path($data['file']), auth()->id());
} catch (Throwable $e) {
Notification::make()->danger()->title('Übernahme nicht möglich')->body($e->getMessage())->send();
return;
} finally {
Storage::disk('local')->delete($data['file']);
}
Audit::log('verleih.imported', $result);
$images = $import->fetchImages(20);
$parts = ["{$result['created']} übernommen", $result['skipped'] ? "{$result['skipped']} waren schon da" : null, self::images($images['loaded']).' geladen'];
$body = implode(', ', array_filter($parts)).'.'.($images['remaining'] ? ' '.self::images($images['remaining']).($images['remaining'] === 1 ? ' steht' : ' stehen').' noch aus – bitte „Bilder nachladen“ klicken.' : '');
Notification::make()->success()->title('Übernommen')->body($body)->persistent()->send();
}),
Action::make('images')->label(fn () => 'Bilder nachladen ('.$import->pendingImages().')')->icon(Heroicon::OutlinedPhoto)->color('gray')
->visible(fn () => $import->pendingImages() > 0)
->action(function () use ($import) {
$images = $import->fetchImages(20);
if ($images['loaded'] === 0 && $images['failed'] > 0) {
Notification::make()->warning()->title('Bilder nicht erreichbar')
->body(self::images($images['failed']).($images['failed'] === 1 ? ' ließ' : ' ließen').' sich von der alten Seite nicht laden (Adresse nicht öffentlich erreichbar oder gelöscht). Sie können sie beim jeweiligen Objekt von Hand hochladen – oder hier „Nicht mehr versuchen“ wählen.')
->persistent()->send();
return;
}
Notification::make()->success()->title(self::images($images['loaded']).' geladen')
->body($images['remaining'] ? self::images($images['remaining']).($images['remaining'] === 1 ? ' steht' : ' stehen').' noch aus – bitte erneut klicken.' : 'Alle Bilder sind da.')->send();
}),
Action::make('forgetImages')->label('Nicht mehr versuchen')->color('gray')->link()
->visible(fn () => $import->pendingImages() > 0)
->requiresConfirmation()->modalDescription('Die fehlenden Bilder werden nicht mehr von der alten Seite geladen. Die Objekte bleiben – Bilder lassen sich dort jederzeit hochladen.')
->action(fn () => Notification::make()->success()->title(self::images($import->forgetMissingImages()).' übersprungen')->send()),
];
}
private static function images(int $count): string
{
return $count === 1 ? '1 Bild' : "{$count} Bilder";
}
}

View file

@ -0,0 +1,194 @@
<?php
namespace Inhaus\Plugins\Verleih\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Search\GlobalSearch;
use App\Support\RichText;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
use Inertia\Inertia;
use Inertia\Response;
use Inhaus\Plugins\Verleih\Labels;
use Inhaus\Plugins\Verleih\Lending;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
use Inhaus\Plugins\Verleih\Photos;
use Inhaus\Plugins\Verleih\Presenter;
use Symfony\Component\HttpFoundation\StreamedResponse;
class ItemController extends Controller
{
public function __construct(private readonly Photos $photos) {}
/** Übersicht: verfügbare zuerst, Filter nach Status und Suche */
public function index(Request $request): Response
{
$data = $request->validate([
'status' => ['nullable', Rule::in(['verfuegbar', 'verliehen'])],
'q' => ['nullable', 'string', 'max:100'],
]);
$user = $request->user();
$query = Item::query()
->when(($data['status'] ?? null) === 'verfuegbar', fn ($q) => $q->where('lent', false))
->when(($data['status'] ?? null) === 'verliehen', fn ($q) => $q->where('lent', true));
if (filled($data['q'] ?? null)) {
GlobalSearch::whereTerms($query, ['title', 'description', 'location'], $data['q']);
}
$items = $query->orderBy('lent')->orderBy('title')->get();
$manage = $user->can(Lending::ABILITY);
return Inertia::render('verleih::Index', [
'items' => $items->map(fn (Item $item) => Presenter::item($item))->all(),
'filters' => ['status' => $data['status'] ?? null, 'q' => $data['q'] ?? ''],
'counts' => ['all' => Item::query()->count(), 'available' => Item::query()->where('lent', false)->count(), 'lent' => Item::query()->where('lent', true)->count()],
'labels' => Labels::all(),
'canManage' => $manage,
'pendingRequests' => $manage ? LoanRequest::query()->where('status', 'pending')->count() : null,
'myRequests' => LoanRequest::query()->with('item')->where('user_id', $user->id)
->where(fn ($q) => $q->where('status', 'pending')->orWhere('updated_at', '>=', now()->subDays(30)))
->latest()->limit(10)->get()
->map(fn (LoanRequest $r) => [...Presenter::request($r), 'item' => Presenter::item($r->item)])->all(),
]);
}
public function show(Request $request, Item $item): Response
{
$user = $request->user();
$manage = $user->can(Lending::ABILITY);
$item->load('lentTo');
return Inertia::render('verleih::Show', [
'item' => Presenter::item($item, $user, full: true),
'labels' => Labels::all(),
'canManage' => $manage,
'myRequest' => ($mine = $item->requests()->where('user_id', $user->id)->where('status', 'pending')->latest()->first()) ? Presenter::request($mine) : null,
'defaultLocation' => $user->location ?: $user->department,
'requests' => $manage
? $item->requests()->with(['user', 'decider'])->latest()->limit(20)->get()->map(fn (LoanRequest $r) => Presenter::request($r))->all()
: [],
]);
}
public function create(Request $request): Response
{
$this->authorizeManage($request);
return $this->editor(null);
}
public function edit(Request $request, Item $item): Response
{
$this->authorizeManage($request);
return $this->editor($item);
}
public function store(Request $request): RedirectResponse
{
$this->authorizeManage($request);
$item = Item::query()->create([...$this->validated($request), 'created_by' => $request->user()->id]);
if ($request->hasFile('image')) {
$this->photos->store($item, $request->file('image'));
}
return to_route('verleih.show', $item)->with('status', "„{$item->title}“ ist angelegt.");
}
public function update(Request $request, Item $item): RedirectResponse
{
$this->authorizeManage($request);
$data = $this->validated($request);
// Nicht mehr verliehen: Person und Zeitraum vergessen
if (! $data['lent']) {
$data += ['lent_to_id' => null, 'lent_since' => null, 'lent_until' => null];
} elseif (! $item->lent) {
$data += ['lent_since' => today()];
}
$item->update($data);
if ($request->hasFile('image')) {
$this->photos->store($item, $request->file('image'));
} elseif ($request->boolean('remove_image')) {
$this->photos->delete($item);
}
return to_route('verleih.show', $item)->with('status', 'Gespeichert.');
}
public function destroy(Request $request, Item $item): RedirectResponse
{
$this->authorizeManage($request);
$this->photos->deleteAll($item);
$item->delete();
return to_route('verleih.index')->with('status', "„{$item->title}“ wurde gelöscht.");
}
/** Zurückgenommen: wieder verfügbar, am angegebenen Ort */
public function giveBack(Request $request, Item $item, Lending $lending): RedirectResponse
{
$this->authorizeManage($request);
$data = $request->validate(['location' => ['nullable', 'string', 'max:200']], [], ['location' => 'Standort']);
$lending->giveBack($item, (string) ($data['location'] ?? ''));
return back()->with('status', "„{$item->title}“ ist wieder verfügbar.");
}
public function image(Item $item, string $size): StreamedResponse
{
$path = $size === 'thumb' ? ($item->thumb_path ?: $item->image_path) : $item->image_path;
abort_unless($path && Storage::disk(Photos::DISK)->exists($path), 404);
return Storage::disk(Photos::DISK)->response($path, null, [
'Content-Type' => 'image/webp',
'Cache-Control' => 'private, max-age=604800',
'X-Content-Type-Options' => 'nosniff',
]);
}
private function editor(?Item $item): Response
{
return Inertia::render('verleih::Editor', [
'item' => $item ? [
...Presenter::item($item),
'description' => $item->description ?? '',
] : null,
'labels' => Labels::all(),
]);
}
/**
* @return array<string, mixed>
*/
private function validated(Request $request): array
{
$labels = Labels::all();
$data = $request->validate([
'title' => ['required', 'string', 'max:200'],
'description' => ['nullable', 'string', 'max:20000'],
'lent' => ['required', 'boolean'],
'location' => ['nullable', 'string', 'max:200'],
'image' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:20480'],
], [], ['title' => 'Titel', 'description' => 'Beschreibung', 'location' => 'Standort', 'image' => $labels['singular'].'foto']);
return [
'title' => trim($data['title']),
'description' => filled($data['description'] ?? null) ? app(RichText::class)->sanitize($data['description']) : null,
'lent' => (bool) $data['lent'],
'location' => filled($data['location'] ?? null) ? trim($data['location']) : null,
];
}
private function authorizeManage(Request $request): void
{
abort_unless($request->user()->can(Lending::ABILITY), 403);
}
}

View file

@ -0,0 +1,71 @@
<?php
namespace Inhaus\Plugins\Verleih\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
use Inhaus\Plugins\Verleih\Labels;
use Inhaus\Plugins\Verleih\Lending;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
use Inhaus\Plugins\Verleih\Presenter;
class RequestController extends Controller
{
public function __construct(private readonly Lending $lending) {}
/** Für das Team: offene Anfragen, darunter die zuletzt beantworteten */
public function index(Request $request): Response
{
abort_unless($request->user()->can(Lending::ABILITY), 403);
$map = fn (LoanRequest $r) => [...Presenter::request($r), 'item' => $r->item ? Presenter::item($r->item) : null];
return Inertia::render('verleih::Requests', [
'pending' => LoanRequest::query()->with(['item', 'user'])->where('status', 'pending')->oldest()->get()->map($map)->all(),
'recent' => LoanRequest::query()->with(['item', 'user', 'decider'])->where('status', '!=', 'pending')->latest('updated_at')->limit(20)->get()->map($map)->all(),
'labels' => Labels::all(),
]);
}
public function store(Request $request, Item $item): RedirectResponse
{
$data = $request->validate([
'location' => ['required', 'string', 'max:200'],
'from' => ['nullable', 'date', 'after_or_equal:today'],
'until' => ['nullable', 'date', 'after_or_equal:today', ...($request->filled('from') ? ['after_or_equal:from'] : [])],
'message' => ['nullable', 'string', 'max:2000'],
], [], ['location' => 'Wunschort', 'from' => 'Von', 'until' => 'Bis', 'message' => 'Nachricht']);
$this->lending->request($item, $request->user(), $data);
return back()->with('status', 'Anfrage gesendet – das Team meldet sich bei Ihnen.');
}
public function accept(Request $request, LoanRequest $loanRequest): RedirectResponse
{
abort_unless($request->user()->can(Lending::ABILITY), 403);
$data = $request->validate(['note' => ['nullable', 'string', 'max:1000']]);
$this->lending->accept($loanRequest, $request->user(), $data['note'] ?? null);
return back()->with('status', "Zugesagt – „{$loanRequest->loadMissing('item')->item->title}“ ist jetzt als verliehen eingetragen.");
}
public function decline(Request $request, LoanRequest $loanRequest): RedirectResponse
{
abort_unless($request->user()->can(Lending::ABILITY), 403);
$data = $request->validate(['note' => ['nullable', 'string', 'max:1000']]);
$this->lending->decline($loanRequest, $request->user(), $data['note'] ?? null);
return back()->with('status', 'Abgesagt – die Person wird benachrichtigt.');
}
public function cancel(Request $request, LoanRequest $loanRequest): RedirectResponse
{
$this->lending->cancel($loanRequest, $request->user());
return back()->with('status', 'Anfrage zurückgezogen.');
}
}

38
src/Labels.php Normal file
View file

@ -0,0 +1,38 @@
<?php
namespace Inhaus\Plugins\Verleih;
use App\Support\Settings;
use Throwable;
/**
* Bezeichnungen – im Backend einstellbar, damit das System auch für anderes als Bilder passt
* (z. B. „Geräteverleih“ / „Gerät“).
*/
class Labels
{
public const DEFAULT_TITLE = 'Bilderverleih';
public const DEFAULT_SINGULAR = 'Bild';
public const DEFAULT_PLURAL = 'Bilder';
/**
* @return array{title: string, singular: string, plural: string}
*/
public static function all(): array
{
try {
$settings = app(Settings::class);
return [
'title' => (string) ($settings->get('verleih.title') ?: self::DEFAULT_TITLE),
'singular' => (string) ($settings->get('verleih.singular') ?: self::DEFAULT_SINGULAR),
'plural' => (string) ($settings->get('verleih.plural') ?: self::DEFAULT_PLURAL),
];
} catch (Throwable) {
// z. B. vor den Migrationen
return ['title' => self::DEFAULT_TITLE, 'singular' => self::DEFAULT_SINGULAR, 'plural' => self::DEFAULT_PLURAL];
}
}
}

168
src/Lending.php Normal file
View file

@ -0,0 +1,168 @@
<?php
namespace Inhaus\Plugins\Verleih;
use App\Models\User;
use App\Notifications\PortalNotification;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Inhaus\Plugins\Verleih\Mail\Notice;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
/**
* Ablauf einer Anfrage: anfragen → das Team sagt zu oder ab. Eine Zusage trägt das Objekt
* gleich als verliehen ein (Ort, Person, Zeitraum). Benachrichtigt wird im Portal und per E-Mail.
*/
class Lending
{
public const ABILITY = 'verleih.manage';
/**
* @param array{location: string, from?: ?string, until?: ?string, message?: ?string} $data
*/
public function request(Item $item, User $user, array $data): LoanRequest
{
if (LoanRequest::query()->where('item_id', $item->id)->where('user_id', $user->id)->where('status', 'pending')->exists()) {
throw ValidationException::withMessages(['location' => 'Sie haben dafür schon eine offene Anfrage.']);
}
$request = LoanRequest::query()->create([
'item_id' => $item->id,
'user_id' => $user->id,
'location' => trim($data['location']),
'from' => $data['from'] ?? null,
'until' => $data['until'] ?? null,
'message' => filled($data['message'] ?? null) ? trim($data['message']) : null,
'status' => 'pending',
]);
$labels = Labels::all();
$managers = $this->managers()->reject(fn (User $m) => $m->is($user));
$title = "Anfrage: {$item->title}";
$body = "{$user->name} möchte „{$item->title}“ nach „{$request->location}“ ausleihen".($request->from ? ' ab '.$request->from->format('d.m.Y') : '').'.';
Notification::send($managers, new PortalNotification($title, $body, route('verleih.requests', absolute: false), 'images'));
foreach ($managers as $manager) {
Mail::to($manager)->queue(new Notice(
mailSubject: "{$labels['singular']} angefragt: {$item->title}",
heading: $item->title,
lines: array_filter([
"{$user->name}".($user->job_title ? " ({$user->job_title})" : '').' möchte „'.$item->title.'“ ausleihen.',
'Wunschort: '.$request->location,
$this->period($request),
$request->message ? 'Nachricht: „'.$request->message.'“' : null,
]),
action: ['Anfrage beantworten', route('verleih.requests')],
replyPerson: $user,
));
}
return $request;
}
public function accept(LoanRequest $request, User $manager, ?string $note = null): void
{
$this->ensurePending($request);
$request->loadMissing(['item', 'user']);
DB::transaction(function () use ($request, $manager, $note) {
$request->forceFill(['status' => 'accepted', 'decided_by' => $manager->id, 'decided_at' => now(), 'note' => $this->clean($note)])->save();
$request->item->forceFill([
'lent' => true,
'location' => $request->location,
'lent_to_id' => $request->user_id,
'lent_since' => $request->from ?? today(),
'lent_until' => $request->until,
])->save();
});
$this->tellRequester($request, 'Zusage', "Ihr Wunsch geht in Ordnung – „{$request->item->title}“ kommt nach „{$request->location}“.", 'images');
}
public function decline(LoanRequest $request, User $manager, ?string $note = null): void
{
$this->ensurePending($request);
$request->loadMissing(['item', 'user']);
$request->forceFill(['status' => 'declined', 'decided_by' => $manager->id, 'decided_at' => now(), 'note' => $this->clean($note)])->save();
$this->tellRequester($request, 'Absage', "Diesmal klappt es leider nicht mit „{$request->item->title}“.", 'images');
}
public function cancel(LoanRequest $request, User $user): void
{
abort_unless($request->user_id === $user->id, 403);
$this->ensurePending($request);
$request->forceFill(['status' => 'cancelled'])->save();
}
/** Zurückgenommen: wieder verfügbar, am angegebenen Ort */
public function giveBack(Item $item, string $location): void
{
$item->forceFill(['lent' => false, 'location' => trim($location) ?: null, 'lent_to_id' => null, 'lent_since' => null, 'lent_until' => null])->save();
}
/**
* Alle, die den Verleih verwalten (bekommen die Anfragen).
*
* @return Collection<int, User>
*/
public function managers(): Collection
{
return User::query()->where('is_active', true)->get()->filter(fn (User $user) => $user->can(self::ABILITY))->values();
}
private function tellRequester(LoanRequest $request, string $kind, string $text, string $icon): void
{
$request->loadMissing(['item', 'user', 'decider']);
$user = $request->user;
if (! $user?->is_active) {
return;
}
$item = $request->item;
$note = $request->note ? ' Hinweis: „'.Str::limit($request->note, 200).'“' : '';
$user->notify(new PortalNotification("{$kind}: {$item->title}", $text.$note, route('verleih.show', $item, false), $icon));
Mail::to($user)->queue(new Notice(
mailSubject: "{$kind} zu Ihrer Anfrage: {$item->title}",
heading: $item->title,
lines: array_filter([$text, $request->note ? 'Hinweis vom Team: „'.$request->note.'“' : null]),
action: [$this->singular().' ansehen', route('verleih.show', $item)],
replyPerson: $request->decider,
));
}
private function ensurePending(LoanRequest $request): void
{
if ($request->status !== 'pending') {
throw ValidationException::withMessages(['status' => 'Diese Anfrage ist schon erledigt.']);
}
}
private function period(LoanRequest $request): ?string
{
return match (true) {
$request->from && $request->until => 'Zeitraum: '.$request->from->format('d.m.Y').' bis '.$request->until->format('d.m.Y'),
(bool) $request->from => 'Ab '.$request->from->format('d.m.Y'),
(bool) $request->until => 'Bis '.$request->until->format('d.m.Y'),
default => null,
};
}
private function clean(?string $note): ?string
{
return filled($note) ? Str::limit(trim($note), 1000, '') : null;
}
private function singular(): string
{
return Labels::all()['singular'];
}
}

52
src/Mail/Notice.php Normal file
View file

@ -0,0 +1,52 @@
<?php
namespace Inhaus\Plugins\Verleih\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\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Inhaus\Plugins\Verleih\Labels;
/**
* Schlichte E-Mail zu einer Anfrage (an das Team bzw. an die anfragende Person).
*/
class Notice extends Mailable implements ShouldQueue
{
use Queueable;
use SerializesModels;
/**
* @param list<string> $lines
* @param array{0: string, 1: string} $action Beschriftung, Adresse
*/
public function __construct(
public string $mailSubject,
public string $heading,
public array $lines,
public array $action,
public ?User $replyPerson = null,
) {}
public function envelope(): Envelope
{
return new Envelope(
subject: $this->mailSubject,
replyTo: $this->replyPerson?->email ? [new Address($this->replyPerson->email, $this->replyPerson->name)] : [],
);
}
public function content(): Content
{
return new Content(view: 'verleih::mail.notice', with: [
'portalName' => app(Branding::class)->portalName(),
'color' => app(Branding::class)->primaryColor(),
'area' => Labels::all()['title'],
]);
}
}

32
src/Models/Item.php Normal file
View file

@ -0,0 +1,32 @@
<?php
namespace Inhaus\Plugins\Verleih\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['title', 'description', 'lent', 'location', 'lent_to_id', 'lent_since', 'lent_until', 'wp_id', 'wp_image_url', 'created_by'])]
class Item extends Model
{
protected $table = 'verleih_items';
protected function casts(): array
{
return ['lent' => 'boolean', 'lent_since' => 'date', 'lent_until' => 'date'];
}
/** @return BelongsTo<User, $this> */
public function lentTo(): BelongsTo
{
return $this->belongsTo(User::class, 'lent_to_id');
}
/** @return HasMany<LoanRequest, $this> */
public function requests(): HasMany
{
return $this->hasMany(LoanRequest::class, 'item_id');
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace Inhaus\Plugins\Verleih\Models;
use App\Models\User;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
#[Fillable(['item_id', 'user_id', 'location', 'from', 'until', 'message', 'status', 'decided_by', 'decided_at', 'note'])]
class LoanRequest extends Model
{
public const STATUSES = [
'pending' => 'Wartet auf Antwort',
'accepted' => 'Zugesagt',
'declined' => 'Abgesagt',
'cancelled' => 'Zurückgezogen',
];
protected $table = 'verleih_requests';
protected function casts(): array
{
return ['from' => 'date', 'until' => 'date', 'decided_at' => 'datetime'];
}
/** @return BelongsTo<Item, $this> */
public function item(): BelongsTo
{
return $this->belongsTo(Item::class, 'item_id');
}
/** @return BelongsTo<User, $this> */
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/** @return BelongsTo<User, $this> */
public function decider(): BelongsTo
{
return $this->belongsTo(User::class, 'decided_by');
}
}

67
src/Photos.php Normal file
View file

@ -0,0 +1,67 @@
<?php
namespace Inhaus\Plugins\Verleih;
use App\Support\Images;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Inhaus\Plugins\Verleih\Models\Item;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Encoders\WebpEncoder;
use Intervention\Image\ImageManager;
use Throwable;
/**
* Foto eines Objekts: verkleinert (max. 2000 px) und als Vorschau, beides ohne Zuschnitt –
* bei Kunstwerken soll nichts abgeschnitten werden. Nur für angemeldete Personen abrufbar.
*/
class Photos
{
public const DISK = 'local';
public function store(Item $item, UploadedFile $file): void
{
try {
Images::withLocalCopy($file, fn (string $local) => $this->storeLocal($item, $local));
} catch (ValidationException $e) {
throw $e;
} catch (Throwable $e) {
report($e);
throw ValidationException::withMessages(['image' => "„{$file->getClientOriginalName()}“ ließ sich nicht als Bild lesen."]);
}
}
/** Aus einer lokalen Datei (Import) */
public function storeLocal(Item $item, string $local): void
{
Images::raiseMemoryLimitFor($local);
$manager = ImageManager::usingDriver(Driver::class);
$image = $manager->decodePath($local)->scaleDown(2000, 2000);
$base = 'verleih/'.$item->id.'/'.Str::random(24);
$disk = Storage::disk(self::DISK);
$disk->put("{$base}.webp", $image->encode(new WebpEncoder(quality: 84))->toString());
$width = $image->width();
$height = $image->height();
$disk->put("{$base}-thumb.webp", $image->scaleDown(720, 720)->encode(new WebpEncoder(quality: 80))->toString());
$this->delete($item);
$item->forceFill(['image_path' => "{$base}.webp", 'thumb_path' => "{$base}-thumb.webp", 'image_width' => $width, 'image_height' => $height])->save();
}
public function delete(Item $item): void
{
if ($item->image_path) {
Storage::disk(self::DISK)->delete([$item->image_path, (string) $item->thumb_path]);
}
$item->forceFill(['image_path' => null, 'thumb_path' => null, 'image_width' => null, 'image_height' => null])->save();
}
public function deleteAll(Item $item): void
{
Storage::disk(self::DISK)->deleteDirectory('verleih/'.$item->id);
}
}

66
src/Presenter.php Normal file
View file

@ -0,0 +1,66 @@
<?php
namespace Inhaus\Plugins\Verleih;
use App\Models\User;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
class Presenter
{
/**
* @return array<string, mixed>
*/
public static function item(Item $item, ?User $viewer = null, bool $full = false): array
{
$version = $item->image_path ? substr(md5($item->image_path), 0, 8) : null;
return [
'id' => $item->id,
'title' => $item->title,
'lent' => $item->lent,
'location' => $item->location,
'thumb_url' => $version ? route('verleih.image', [$item, 'thumb', 'v' => $version]) : null,
'image_url' => $version ? route('verleih.image', [$item, 'full', 'v' => $version]) : null,
'width' => $item->image_width,
'height' => $item->image_height,
'url' => route('verleih.show', $item),
...($full ? [
'description' => $item->description,
'lent_since' => $item->lent_since?->toDateString(),
'lent_until' => $item->lent_until?->toDateString(),
// Wer es hat, sieht nur das Team
'lent_to' => $viewer?->can(Lending::ABILITY) && $item->relationLoaded('lentTo') && $item->lentTo ? self::person($item->lentTo) : null,
] : []),
];
}
/**
* @return array<string, mixed>
*/
public static function request(LoanRequest $request): array
{
return [
'id' => $request->id,
'status' => $request->status,
'status_label' => LoanRequest::STATUSES[$request->status] ?? $request->status,
'location' => $request->location,
'from' => $request->from?->toDateString(),
'until' => $request->until?->toDateString(),
'message' => $request->message,
'note' => $request->note,
'created_at' => $request->created_at?->toIso8601String(),
'decided_at' => $request->decided_at?->toIso8601String(),
'user' => $request->relationLoaded('user') && $request->user ? self::person($request->user) : null,
'decider' => $request->relationLoaded('decider') && $request->decider ? self::person($request->decider) : null,
];
}
/**
* @return array<string, mixed>
*/
public static function person(User $user): array
{
return ['id' => $user->id, 'name' => $user->name, 'initials' => $user->initials, 'avatar_url' => $user->avatarUrl(96), 'job_title' => $user->job_title, 'department' => $user->department];
}
}

59
src/VerleihPlugin.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace Inhaus\Plugins\Verleih;
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\Storage;
use Illuminate\Support\Str;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
/**
* Verleih – z. B. die Bilder des Künstlerteams: wer hat welches Bild wo, anfragen im Portal.
*/
class VerleihPlugin extends Plugin
{
public function register(): void
{
$labels = Labels::all();
$this->app->make(Navigation::class)->add('verleih', $labels['title'], '/verleih', active: 'verleih.*', sort: 79, icon: 'images');
$this->app->make(Abilities::class)->define(Lending::ABILITY, 'Verleih verwalten (Objekte pflegen, Anfragen beantworten)', 'Verleih', portal: true);
$this->app->make(GlobalSearch::class)->add('verleih', $labels['title'], 'images', function (User $user, string $search, int $limit) {
$query = Item::query();
GlobalSearch::whereTerms($query, ['title', 'description', 'location'], $search);
return $query->orderBy('title')->limit($limit)->get()->map(fn (Item $item) => [
'title' => $item->title,
'url' => '/verleih/'.$item->id,
'excerpt' => GlobalSearch::excerpt(strip_tags((string) $item->description), $search),
'meta' => $item->lent ? 'Verliehen'.($item->location ? ' · '.$item->location : '') : 'Verfügbar'.($item->location ? ' · '.$item->location : ''),
])->all();
}, sort: 75);
// Redaktion: offene Anfragen fürs Team
$editorial = $this->app->make(Editorial::class);
$editorial->add('verleih', $labels['title'], 'verleih::EditorialRequests', 37,
fn (User $user) => $user->can(Lending::ABILITY),
fn () => ['pending' => LoanRequest::query()->with(['item', 'user'])->where('status', 'pending')->oldest()->limit(20)->get()
->map(fn (LoanRequest $r) => [...Presenter::request($r), 'item' => $r->item ? Presenter::item($r->item) : null])->all()]);
$editorial->meta('verleih', icon: 'images',
todo: function () {
$count = LoanRequest::query()->where('status', 'pending')->count();
return ['count' => $count, 'label' => $count === 1 ? 'Anfrage zu beantworten' : 'Anfragen zu beantworten'];
},
create: fn () => ['label' => Str::ucfirst(Labels::all()['singular']).' erfassen', 'href' => route('verleih.create')]);
}
public function uninstall(): void
{
Storage::disk(Photos::DISK)->deleteDirectory('verleih');
}
}

263
src/WordpressImport.php Normal file
View file

@ -0,0 +1,263 @@
<?php
namespace Inhaus\Plugins\Verleih;
use App\Support\RichText;
use App\Support\SafeOutbound;
use Illuminate\Support\Facades\Http;
use Inhaus\Plugins\Verleih\Models\Item;
use RuntimeException;
use SimpleXMLElement;
use Throwable;
use XMLReader;
/**
* Übernahme aus dem WordPress-Plugin „FL-Verleihsystem“: WordPress-Exportdatei (WXR,
* „Werkzeuge → Daten exportieren → Objekte“) mit den Beiträgen vom Typ bv_objekt,
* ihren Beitragsbildern und den Feldern _bv_verliehen (ja/nein) und _bv_verleihort.
*
* Schon übernommene Objekte (gleiche WordPress-ID) bleiben unverändert – ein zweiter Lauf
* überschreibt also keine Änderungen, die im Portal gemacht wurden. Bilder werden danach
* in Etappen heruntergeladen (fetchImages), damit keine Anfrage zu lange dauert.
*/
class WordpressImport
{
public const MAX_BYTES = 20 * 1024 * 1024;
private const NS_WP = ['http://wordpress.org/export/1.2/', 'http://wordpress.org/export/1.1/', 'http://wordpress.org/export/1.0/'];
private const NS_CONTENT = 'http://purl.org/rss/1.0/modules/content/';
public function __construct(private readonly Photos $photos, private readonly RichText $richText) {}
/**
* @return array{created: int, skipped: int, found: int}
*/
public function import(string $file, ?int $userId = null): array
{
$objects = [];
$attachments = [];
$this->read($file, function (array $item) use (&$objects, &$attachments) {
if ($item['type'] === 'attachment') {
$attachments[$item['wp_id']] = $item['attachment_url'];
} elseif ($item['type'] === 'bv_objekt' && $item['status'] === 'publish') {
$objects[] = $item;
}
});
if ($objects === [] && $attachments === []) {
throw new RuntimeException('In der Datei sind keine Objekte des Verleihsystems (bv_objekt). Bitte in WordPress unter „Werkzeuge → Daten exportieren“ die „Objekte“ exportieren.');
}
$created = 0;
$skipped = 0;
foreach ($objects as $object) {
if (Item::query()->where('wp_id', $object['wp_id'])->exists()) {
$skipped++;
continue;
}
$image = $attachments[$object['meta']['_thumbnail_id'] ?? 0] ?? null;
Item::query()->create([
'title' => mb_substr($object['title'] ?: 'Ohne Titel', 0, 200),
'description' => $this->description($object['content']),
'lent' => ($object['meta']['_bv_verliehen'] ?? 'nein') === 'ja',
'location' => filled($object['meta']['_bv_verleihort'] ?? null) ? mb_substr(trim($object['meta']['_bv_verleihort']), 0, 200) : null,
'wp_id' => $object['wp_id'],
'wp_image_url' => $image && str_starts_with($image, 'http') ? mb_substr($image, 0, 1000) : null,
'created_by' => $userId,
]);
$created++;
}
return ['created' => $created, 'skipped' => $skipped, 'found' => count($objects)];
}
/** Wie viele Bilder aus dem Import noch fehlen */
public function pendingImages(): int
{
return Item::query()->whereNotNull('wp_image_url')->whereNull('image_path')->count();
}
/**
* Bilder der übernommenen Objekte herunterladen – so viele, wie in die Zeit passen.
*
* @return array{loaded: int, failed: int, remaining: int}
*/
public function fetchImages(float $seconds = 20.0): array
{
$start = microtime(true);
$loaded = 0;
$failed = 0;
foreach (Item::query()->whereNotNull('wp_image_url')->whereNull('image_path')->orderBy('id')->cursor() as $item) {
if (microtime(true) - $start > $seconds) {
break;
}
if ($this->download($item)) {
$item->forceFill(['wp_image_url' => null])->save();
$loaded++;
} else {
$failed++;
}
}
return ['loaded' => $loaded, 'failed' => $failed, 'remaining' => $this->pendingImages()];
}
/** Bild nicht zu bekommen: Adresse vergessen, damit es nicht ewig als „ausstehend“ zählt */
public function forgetMissingImages(): int
{
return Item::query()->whereNotNull('wp_image_url')->whereNull('image_path')->update(['wp_image_url' => null]);
}
private function download(Item $item): bool
{
$url = (string) $item->wp_image_url;
// Keine internen Adressen abrufen (die Adresse stammt aus der hochgeladenen Datei)
if (! SafeOutbound::isPublicUrl($url)) {
return false;
}
$tmp = tempnam(sys_get_temp_dir(), 'verleih');
try {
$response = Http::timeout(30)->connectTimeout(10)->withOptions([
...SafeOutbound::options(),
'sink' => $tmp,
'progress' => function ($total, $downloaded) {
if ($total > self::MAX_BYTES || $downloaded > self::MAX_BYTES) {
throw new RuntimeException('Datei zu groß');
}
},
])->get($url);
if (! $response->successful() || @getimagesize($tmp) === false) {
return false;
}
$this->photos->storeLocal($item, $tmp);
return true;
} catch (Throwable) {
return false;
} finally {
@unlink($tmp);
}
}
/**
* WordPress speichert Text ohne Absätze (die setzt erst die Anzeige) und mit Block-Kommentaren.
*/
private function description(string $content): ?string
{
$html = preg_replace(['/<!--.*?-->/s', '/\[\/?[a-z_-]+[^\]]*\]/i'], '', $content) ?? '';
$html = trim(str_replace(["\r\n", "\r"], "\n", $html));
if ($html === '') {
return null;
}
if (! preg_match('/<(p|div|h[1-6]|ul|ol|blockquote|figure)\b/i', $html)) {
$html = collect(preg_split('/\n{2,}/', $html) ?: [])
->map(fn (string $paragraph) => '<p>'.nl2br(trim($paragraph), false).'</p>')
->implode('');
}
$clean = trim($this->richText->sanitize($html));
return $clean === '' ? null : $clean;
}
/**
* @param callable(array<string, mixed>): void $callback
*/
private function read(string $file, callable $callback): void
{
// Keine eigenen Entitäten (Schutz vor „Billion Laughs“ – WordPress-Exporte nutzen keine)
if (str_contains((string) @file_get_contents($file, false, null, 0, 65536), '<!ENTITY')) {
throw new RuntimeException('Die Datei enthält nicht unterstützte XML-Entitäten.');
}
$reader = new XMLReader;
if (! @$reader->open($file, null, LIBXML_NONET | LIBXML_COMPACT | LIBXML_PARSEHUGE)) {
throw new RuntimeException('Die Datei konnte nicht gelesen werden.');
}
$isWxr = false;
try {
while (@$reader->read()) {
if ($reader->nodeType !== XMLReader::ELEMENT) {
continue;
}
if ($reader->name === 'wp:wxr_version') {
$isWxr = true;
} elseif ($reader->name === 'item') {
if (! $isWxr) {
throw new RuntimeException('Das ist keine WordPress-Exportdatei (WXR).');
}
$element = $this->element($reader->readOuterXml());
if ($element) {
$callback($this->item($element));
}
$reader->next();
}
}
} finally {
$reader->close();
}
if (! $isWxr) {
throw new RuntimeException('Das ist keine WordPress-Exportdatei (WXR).');
}
}
/**
* Einzelnes Element mit festen Namensräumen neu aufbauen (WordPress 1.0–1.2 → 1.2),
* wie der WordPress-Import des Portals.
*/
private function element(string $xml): ?SimpleXMLElement
{
$declarations = 'xmlns:wp="'.self::NS_WP[0].'" xmlns:content="'.self::NS_CONTENT.'" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"';
$xml = preg_replace('/\s+xmlns:[A-Za-z0-9_-]+="[^"]*"/', '', $xml) ?? '';
$root = @simplexml_load_string('<root '.$declarations.'>'.$xml.'</root>', SimpleXMLElement::class, LIBXML_NOCDATA | LIBXML_NONET | LIBXML_PARSEHUGE);
return $root ? ($root->xpath('./*')[0] ?? null) : null;
}
/**
* @return array<string, mixed>
*/
private function item(SimpleXMLElement $element): array
{
$wp = $element->children(self::NS_WP[0]);
$meta = [];
foreach ($wp->postmeta as $postmeta) {
$pm = $postmeta->children(self::NS_WP[0]);
$meta[(string) $pm->meta_key] = (string) $pm->meta_value;
}
return [
'wp_id' => (int) $wp->post_id,
'type' => (string) $wp->post_type,
'status' => (string) $wp->status,
'title' => html_entity_decode(trim((string) $element->title), ENT_QUOTES | ENT_HTML5),
'content' => (string) $element->children(self::NS_CONTENT)->encoded,
'attachment_url' => trim((string) $wp->attachment_url),
'meta' => $meta,
];
}
}

230
tests/VerleihTest.php Normal file
View file

@ -0,0 +1,230 @@
<?php
namespace Tests\Plugins\Verleih;
use App\Models\Role;
use App\Models\User;
use App\Notifications\PortalNotification;
use App\Support\SafeOutbound;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Storage;
use Inertia\Testing\AssertableInertia as Assert;
use Inhaus\Plugins\Verleih\Mail\Notice;
use Inhaus\Plugins\Verleih\Models\Item;
use Inhaus\Plugins\Verleih\Models\LoanRequest;
use Inhaus\Plugins\Verleih\WordpressImport;
use Tests\TestCase;
/**
* Läuft innerhalb einer Inhaus-Installation mit dem Plugin unter plugins/verleih:
* vendor-dev/bin/phpunit plugins/verleih/tests
*/
class VerleihTest extends TestCase
{
use RefreshDatabase;
private ?string $previousState = null;
private User $artist;
protected function setUp(): void
{
// Plugin aktivieren, bevor die Anwendung startet – so laufen seine Migrationen mit
$file = getcwd().'/storage/app/plugins.json';
$this->previousState = is_file($file) ? file_get_contents($file) : null;
$state = json_decode($this->previousState ?? '{}', true) ?: [];
$state['verleih'] = ['enabled' => true];
file_put_contents($file, json_encode($state));
parent::setUp();
Storage::fake('local');
$role = Role::query()->create(['name' => 'Künstlerteam']);
$role->grants()->create(['ability' => 'verleih.manage']);
$this->artist = User::factory()->withRoles([$role])->create(['first_name' => 'Kim', 'last_name' => 'Kunst']);
}
protected function tearDown(): void
{
$file = storage_path('app/plugins.json');
$this->previousState === null ? @unlink($file) : file_put_contents($file, $this->previousState);
parent::tearDown();
}
private function item(array $overrides = []): Item
{
return Item::query()->create(['title' => 'Sommerwiese', 'description' => '<p>Acryl auf Leinwand</p>', 'lent' => false, 'location' => 'Lager', ...$overrides]);
}
public function test_team_manages_pictures_everyone_sees_them_available_first(): void
{
$colleague = User::factory()->create();
$this->actingAs($colleague)->get('/verleih/neu')->assertForbidden();
$this->actingAs($colleague)->post('/verleih', ['title' => 'X', 'lent' => 0])->assertForbidden();
$this->actingAs($this->artist)->post('/verleih', [
'title' => 'Blaue Stunde',
'description' => '<p>Öl</p><script>alert(1)</script>',
'lent' => 1,
'location' => 'Verwaltung',
'image' => UploadedFile::fake()->image('bild.jpg', 3000, 2000),
])->assertRedirect();
$lent = Item::query()->where('title', 'Blaue Stunde')->firstOrFail();
$this->assertTrue($lent->lent);
$this->assertStringNotContainsString('<script', (string) $lent->description);
$this->assertSame(2000, $lent->image_width, 'Verkleinert auf 2000 px, ohne Zuschnitt');
$this->assertSame(1333, $lent->image_height);
$this->item(['title' => 'Sommerwiese']);
$this->actingAs($colleague)->get('/verleih')->assertInertia(fn (Assert $p) => $p
->component('verleih::Index')
->where('items.0.title', 'Sommerwiese')->where('items.0.lent', false)
->where('items.1.title', 'Blaue Stunde')->where('items.1.location', 'Verwaltung')
->where('canManage', false)->where('pendingRequests', null)
->where('labels.singular', 'Bild'));
$this->actingAs($colleague)->get('/verleih?status=verliehen')->assertInertia(fn (Assert $p) => $p->has('items', 1)->where('counts.available', 1));
$this->actingAs($colleague)->get("/verleih/bilder/{$lent->id}/thumb")->assertOk();
auth()->logout();
$this->get("/verleih/bilder/{$lent->id}/thumb")->assertRedirect('/login');
}
public function test_request_accept_decline_and_notifications(): void
{
Notification::fake();
Mail::fake();
$item = $this->item();
[$ada, $bob] = User::factory()->count(2)->create()->all();
$this->actingAs($ada)->post("/verleih/{$item->id}/anfragen", ['location' => 'Besprechungsraum 2. OG', 'from' => today()->addDay()->toDateString(), 'message' => 'Für die Jubiläumsfeier'])
->assertSessionHasNoErrors();
$this->actingAs($ada)->post("/verleih/{$item->id}/anfragen", ['location' => 'Nochmal'])->assertSessionHasErrors('location');
$this->actingAs($bob)->post("/verleih/{$item->id}/anfragen", ['location' => 'Empfang'])->assertSessionHasNoErrors();
Notification::assertSentTo($this->artist, PortalNotification::class, fn ($n) => str_contains($n->body, 'Besprechungsraum'));
Mail::assertQueued(Notice::class, fn (Notice $mail) => $mail->hasTo($this->artist->email) && $mail->replyPerson?->is($ada));
Notification::assertNotSentTo($bob, PortalNotification::class);
[$first, $second] = LoanRequest::query()->orderBy('id')->get()->all();
$this->actingAs($ada)->post("/verleih/anfragen/{$first->id}/zusagen")->assertForbidden();
$this->actingAs($this->artist)->get('/verleih/anfragen')->assertInertia(fn (Assert $p) => $p->has('pending', 2)->where('pending.0.user.id', $ada->id));
$this->actingAs($this->artist)->post("/verleih/anfragen/{$first->id}/zusagen", ['note' => 'Bringen wir Montag vorbei'])->assertSessionHasNoErrors();
$item->refresh();
$this->assertTrue($item->lent);
$this->assertSame('Besprechungsraum 2. OG', $item->location);
$this->assertSame($ada->id, $item->lent_to_id);
Notification::assertSentTo($ada, PortalNotification::class, fn ($n) => str_starts_with($n->title, 'Zusage') && str_contains($n->body, 'Montag'));
// Wer es hat, sieht nur das Team
$this->actingAs($bob)->get("/verleih/{$item->id}")->assertInertia(fn (Assert $p) => $p->where('item.lent_to', null)->where('myRequest.location', 'Empfang'));
$this->actingAs($this->artist)->get("/verleih/{$item->id}")->assertInertia(fn (Assert $p) => $p->where('item.lent_to.id', $ada->id)->has('requests', 2));
$this->actingAs($this->artist)->post("/verleih/anfragen/{$second->id}/absagen", ['note' => 'Ist gerade vergeben'])->assertSessionHasNoErrors();
$this->assertSame('declined', $second->fresh()->status);
Notification::assertSentTo($bob, PortalNotification::class, fn ($n) => str_starts_with($n->title, 'Absage'));
$this->actingAs($this->artist)->post("/verleih/anfragen/{$second->id}/zusagen")->assertSessionHasErrors('status');
// Zurückgenommen
$this->actingAs($this->artist)->post("/verleih/{$item->id}/zurueck", ['location' => 'Lager Künstlerteam'])->assertRedirect();
$item->refresh();
$this->assertFalse($item->lent);
$this->assertNull($item->lent_to_id);
$this->assertSame('Lager Künstlerteam', $item->location);
}
public function test_requesters_can_withdraw_only_their_own(): void
{
$item = $this->item();
[$ada, $bob] = User::factory()->count(2)->create()->all();
$this->actingAs($ada)->post("/verleih/{$item->id}/anfragen", ['location' => 'Empfang']);
$request = LoanRequest::query()->sole();
$this->actingAs($bob)->delete("/verleih/anfragen/{$request->id}")->assertForbidden();
$this->actingAs($ada)->delete("/verleih/anfragen/{$request->id}")->assertRedirect();
$this->assertSame('cancelled', $request->fresh()->status);
}
public function test_import_from_the_wordpress_plugin(): void
{
$file = tempnam(sys_get_temp_dir(), 'wxr');
file_put_contents($file, <<<'XML'
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/">
<channel>
<title>Altes Intranet</title>
<wp:wxr_version>1.2</wp:wxr_version>
<item>
<title>Sonnenblumen</title>
<content:encoded><![CDATA[<!-- wp:paragraph -->Öl auf Leinwand, 60 × 80 cm
Gemalt von Anna[gallery ids="1"]<!-- /wp:paragraph -->]]></content:encoded>
<wp:post_id>11</wp:post_id>
<wp:status>publish</wp:status>
<wp:post_type>bv_objekt</wp:post_type>
<wp:postmeta><wp:meta_key>_bv_verliehen</wp:meta_key><wp:meta_value><![CDATA[ja]]></wp:meta_value></wp:postmeta>
<wp:postmeta><wp:meta_key>_bv_verleihort</wp:meta_key><wp:meta_value><![CDATA[Haus B, Flur]]></wp:meta_value></wp:postmeta>
<wp:postmeta><wp:meta_key>_thumbnail_id</wp:meta_key><wp:meta_value><![CDATA[21]]></wp:meta_value></wp:postmeta>
</item>
<item>
<title>Entwurf</title>
<wp:post_id>12</wp:post_id>
<wp:status>draft</wp:status>
<wp:post_type>bv_objekt</wp:post_type>
</item>
<item>
<title>Hafen &amp; Meer</title>
<content:encoded><![CDATA[<p>Aquarell</p>]]></content:encoded>
<wp:post_id>13</wp:post_id>
<wp:status>publish</wp:status>
<wp:post_type>bv_objekt</wp:post_type>
<wp:postmeta><wp:meta_key>_bv_verliehen</wp:meta_key><wp:meta_value><![CDATA[nein]]></wp:meta_value></wp:postmeta>
</item>
<item>
<title>sonnenblumen.jpg</title>
<wp:post_id>21</wp:post_id>
<wp:status>inherit</wp:status>
<wp:post_type>attachment</wp:post_type>
<wp:attachment_url><![CDATA[https://intranet.example.org/wp-content/uploads/sonnenblumen.jpg]]></wp:attachment_url>
</item>
</channel>
</rss>
XML);
$import = app(WordpressImport::class);
$result = $import->import($file, $this->artist->id);
$this->assertSame(['created' => 2, 'skipped' => 0, 'found' => 2], $result);
$sun = Item::query()->where('wp_id', 11)->sole();
$this->assertTrue($sun->lent);
$this->assertSame('Haus B, Flur', $sun->location);
$this->assertSame('<p>Öl auf Leinwand, 60 × 80 cm</p><p>Gemalt von Anna</p>', $sun->description);
$this->assertSame('https://intranet.example.org/wp-content/uploads/sonnenblumen.jpg', $sun->wp_image_url);
$this->assertSame('Hafen & Meer', Item::query()->where('wp_id', 13)->sole()->title);
$this->assertSame(1, $import->pendingImages());
// Bilder nachladen
SafeOutbound::fakeResolve(['intranet.example.org' => '93.184.216.34']);
$jpeg = UploadedFile::fake()->image('x.jpg', 800, 600)->getContent();
Http::fake(['intranet.example.org/*' => Http::response($jpeg, 200, ['Content-Type' => 'image/jpeg'])]);
$this->assertSame(['loaded' => 1, 'failed' => 0, 'remaining' => 0], $import->fetchImages());
$this->assertNotNull($sun->fresh()->image_path);
// Zweiter Lauf überschreibt nichts
$sun->update(['location' => 'Im Portal geändert']);
$this->assertSame(['created' => 0, 'skipped' => 2, 'found' => 2], $import->import($file));
$this->assertSame('Im Portal geändert', $sun->fresh()->location);
file_put_contents($file, '<?xml version="1.0"?><!DOCTYPE x [<!ENTITY a "b">]><rss></rss>');
$this->expectExceptionMessage('Entitäten');
$import->import($file);
}
}

5
vite.config.js Normal file
View file

@ -0,0 +1,5 @@
import { defineConfig } from 'vite';
import { inhausPlugin } from './inhaus-sdk/vite.js';
// Baut resources/js/{pages,widgets,blocks,…} nach dist/ (siehe inhaus-sdk/vite.js)
export default defineConfig(inhausPlugin());