diff --git a/app/Http/Controllers/GalleryController.php b/app/Http/Controllers/GalleryController.php index 3b049cd..0b8110b 100644 --- a/app/Http/Controllers/GalleryController.php +++ b/app/Http/Controllers/GalleryController.php @@ -230,4 +230,18 @@ class GalleryController extends BaseController $image->saveOrFail(); return "OK"; } + + public function saveImage($name, Request $request) { + $gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name); + $image = Image::query()->where("id", "=", $request->input("id"))->firstOrFail(); + if($image->gallery != $gallery->id) { + abort(400); + } + + $image->name = $request->input("name"); + $image->description = $request->input("description"); + $image->rating = $request->input("rating"); + $image->saveOrFail(); + return "OK"; + } } diff --git a/resources/views/gallery/images.blade.php b/resources/views/gallery/images.blade.php index 40ab776..b2db2b5 100644 --- a/resources/views/gallery/images.blade.php +++ b/resources/views/gallery/images.blade.php @@ -32,26 +32,28 @@ - + + @@ -59,7 +61,9 @@ @endsection @section('js') diff --git a/routes/web.php b/routes/web.php index 6abd065..e82d7ae 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,6 +44,7 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function Route::post("/g/{url}/edit", [\App\Http\Controllers\GalleryController::class, 'editGallery']); Route::get("/g/{url}/setDefault", [\App\Http\Controllers\GalleryController::class, 'setDefault']); Route::get("/g/{url}/delete", [\App\Http\Controllers\GalleryController::class, 'deleteImage']); + Route::post("/g/{url}/save", [\App\Http\Controllers\GalleryController::class, 'saveImage']); }); Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);