- Galerien sind nun eine Entität - es kann mehrere geben

- Neues Sparkbooth-Upload-Feature: Endpoint /api/sparkbooth/upload (Token-basiert pro Galerie), Controller Api/SparkboothUploadController, Migration 2026_01_21_000001_add_upload_fields_to_galleries_table.php mit Upload-Flags/Token/Expiry;
    Galerie-Modell und Factory/Seeder entsprechend erweitert.
  - Filament: Neue Setup-Seite SparkboothSetup (mit View) zur schnellen Galerie- und Token-Erstellung inkl. QR/Endpoint/Snippet;
    Galerie-Link-Views nutzen jetzt simple-qrcode (Composer-Dependency hinzugefügt) und bieten PNG-Download.
  - Galerie-Tabelle: Slug/Pfad-Spalten entfernt, Action „Link-Details“ mit Modal; Created-at-Spalte hinzugefügt.
  - Zugriffshärtung: Galerie-IDs in API (ImageController, Download/Print) geprüft; GalleryAccess/Middleware + Gallery-Modell/Slug-UUID
    eingeführt; GalleryAccess-Inertia-Seite.
  - UI/UX: LoadingSpinner/StyledImageDisplay verbessert, Delete-Confirm, Übersetzungen ergänzt.
This commit is contained in:
2025-12-04 07:52:50 +01:00
parent 52dc61ca16
commit f5da8ed877
49 changed files with 2243 additions and 165 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Gallery>
*/
class GalleryFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$name = $this->faker->words(2, true);
$slug = Str::uuid()->toString();
return [
'name' => $name,
'slug' => $slug,
'title' => $name,
'images_path' => 'uploads/'.$slug,
'is_public' => true,
'allow_ai_styles' => true,
'allow_print' => true,
'require_password' => false,
'password_hash' => null,
'expires_at' => null,
'access_duration_minutes' => null,
'upload_enabled' => false,
'upload_token_hash' => null,
'upload_token_expires_at' => null,
];
}
}

View File

@@ -110,6 +110,10 @@ return new class extends Migration
{
$defaults = [
'gallery_heading' => 'Style Gallery',
'require_gallery_password' => false,
'gallery_password_hash' => null,
'gallery_expires_at' => null,
'gallery_access_duration_minutes' => null,
'new_image_timespan_minutes' => 60,
'image_refresh_interval' => 30_000,
'max_number_of_copies' => 3,
@@ -124,9 +128,10 @@ return new class extends Migration
'image_refresh_interval',
'max_number_of_copies',
'default_style_id',
'gallery_access_duration_minutes',
];
$boolKeys = ['show_print_button'];
$boolKeys = ['show_print_button', 'require_gallery_password'];
$now = now();

View File

@@ -0,0 +1,69 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('galleries', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('title');
$table->string('images_path')->default('uploads');
$table->boolean('is_public')->default(true);
$table->boolean('allow_ai_styles')->default(true);
$table->boolean('allow_print')->default(true);
$table->boolean('require_password')->default(false);
$table->string('password_hash')->nullable();
$table->timestamp('expires_at')->nullable();
$table->unsignedInteger('access_duration_minutes')->nullable();
$table->timestamps();
});
$defaultGalleryId = DB::table('galleries')->insertGetId([
'name' => 'Default Gallery',
'slug' => Str::uuid()->toString(),
'title' => 'Style Gallery',
'images_path' => 'uploads',
'is_public' => true,
'allow_ai_styles' => true,
'allow_print' => true,
'require_password' => false,
'password_hash' => null,
'expires_at' => null,
'access_duration_minutes' => null,
'created_at' => now(),
'updated_at' => now(),
]);
Schema::table('images', function (Blueprint $table) use ($defaultGalleryId): void {
$table->foreignId('gallery_id')
->after('id')
->default($defaultGalleryId)
->constrained();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('images', function (Blueprint $table): void {
if (Schema::hasColumn('images', 'gallery_id')) {
$table->dropConstrainedForeignId('gallery_id');
}
});
Schema::dropIfExists('galleries');
}
};

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('galleries', function (Blueprint $table): void {
$table->boolean('upload_enabled')->default(false)->after('access_duration_minutes');
$table->string('upload_token_hash')->nullable()->after('upload_enabled');
$table->timestamp('upload_token_expires_at')->nullable()->after('upload_token_hash');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('galleries', function (Blueprint $table): void {
$table->dropColumn([
'upload_enabled',
'upload_token_hash',
'upload_token_expires_at',
]);
});
}
};

View File

@@ -20,6 +20,7 @@ class DatabaseSeeder extends Seeder
AiModelSeeder::class,
AiModelApiProviderSeeder::class,
SettingSeeder::class,
GallerySeeder::class,
StyleSeeder::class,
]);
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Seeders;
use App\Models\Gallery;
use App\Settings\GeneralSettings;
use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class GallerySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
/** @var \App\Settings\GeneralSettings $settings */
$settings = app(GeneralSettings::class);
Gallery::firstOrCreate(
['slug' => Str::uuid()->toString()],
[
'name' => 'Default Gallery',
'title' => $settings->gallery_heading ?? 'Style Gallery',
'images_path' => 'uploads',
'is_public' => true,
'allow_ai_styles' => true,
'allow_print' => true,
'require_password' => (bool) $settings->require_gallery_password,
'password_hash' => $settings->gallery_password_hash,
'expires_at' => $settings->gallery_expires_at,
'access_duration_minutes' => $settings->gallery_access_duration_minutes,
'upload_enabled' => false,
'upload_token_hash' => null,
'upload_token_expires_at' => null,
]
);
}
}

View File

@@ -21,6 +21,10 @@ class SettingSeeder extends Seeder
'image_refresh_interval' => 30_000,
'max_number_of_copies' => 3,
'show_print_button' => true,
'require_gallery_password' => false,
'gallery_password_hash' => null,
'gallery_expires_at' => null,
'gallery_access_duration_minutes' => null,
'selected_printer' => null,
'custom_printer_address' => null,
'default_style_id' => null,