inhaus-plugin-verleih/database/migrations/2026_10_28_000001_create_verleih_tables.php
Friederich Loheide 14aaa16b30 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>
2026-09-28 15:17:47 +00:00

53 lines
2.4 KiB
PHP

<?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');
}
};