- 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:
@@ -2,29 +2,48 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Gallery;
|
||||
use App\Models\Image;
|
||||
use App\Settings\GeneralSettings;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function __construct(private GeneralSettings $settings) {}
|
||||
|
||||
public function index()
|
||||
public function index(Request $request, ?Gallery $gallery = null)
|
||||
{
|
||||
$galleryHeading = $this->settings->gallery_heading;
|
||||
$gallery = $gallery ?: Gallery::first();
|
||||
|
||||
if (! $gallery) {
|
||||
abort(404, 'Gallery not found');
|
||||
}
|
||||
|
||||
$galleryHeading = $gallery->title ?: $this->settings->gallery_heading;
|
||||
$newImageTimespanMinutes = $this->settings->new_image_timespan_minutes;
|
||||
|
||||
$images = Image::all()->map(function ($image) use ($newImageTimespanMinutes) {
|
||||
$image->is_new = Carbon::parse($image->created_at)->diffInMinutes(Carbon::now()) <= $newImageTimespanMinutes;
|
||||
$image->path = 'storage/'.$image->path;
|
||||
$images = Image::where('gallery_id', $gallery->id)
|
||||
->orderByDesc('updated_at')
|
||||
->get()
|
||||
->map(function ($image) use ($newImageTimespanMinutes) {
|
||||
$image->is_new = Carbon::parse($image->created_at)->diffInMinutes(Carbon::now()) <= $newImageTimespanMinutes;
|
||||
$image->path = asset('storage/'.$image->path);
|
||||
|
||||
return $image;
|
||||
});
|
||||
return $image;
|
||||
});
|
||||
|
||||
return Inertia::render('Home', [
|
||||
'galleryHeading' => $galleryHeading,
|
||||
'gallery' => [
|
||||
'id' => $gallery->id,
|
||||
'slug' => $gallery->slug,
|
||||
'title' => $galleryHeading,
|
||||
'allow_ai_styles' => $gallery->allow_ai_styles,
|
||||
'allow_print' => $gallery->allow_print,
|
||||
'images_path' => $gallery->images_path,
|
||||
],
|
||||
'images' => $images,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user