Stuff
This commit is contained in:
parent
5cf01e160d
commit
722107ec10
4 changed files with 22 additions and 5 deletions
|
@ -102,10 +102,6 @@ class GalleryController extends BaseController
|
|||
|
||||
public function editGalleryView($name, Request $request) {
|
||||
$gallery = Gallery::getByTenantAndUrl(session("current_tenant_id"), $name);
|
||||
/*session(['_old_input.name' => $gallery->name]);
|
||||
session(['_old_input.description' => $gallery->description]);
|
||||
session(['_old_input.date' => $gallery->gallery_create_time]);
|
||||
session(['_old_input.url' => $gallery->url]);*/
|
||||
return view("gallery.new", ["gallery" => $gallery]);
|
||||
}
|
||||
|
||||
|
@ -169,4 +165,16 @@ class GalleryController extends BaseController
|
|||
$gallery->saveOrFail();
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public function deleteImage($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);
|
||||
}
|
||||
|
||||
Storage::disk($image->driver)->delete($image->path);
|
||||
$image->delete();
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class ResizeImage implements ShouldQueue
|
|||
|
||||
$image = ImageResize::createFromString($file);
|
||||
$image->resizeToLongSide($this->size);
|
||||
Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString());
|
||||
Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
<input style="display: none;" name="edit-id" id="edit-id" placeholder="ID" class="form-control">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="deleteImage" class="btn btn-danger">Delete</button>
|
||||
<button type="button" id="makeGalleryDefault" class="btn btn-warning">Make Galery Preview</button>
|
||||
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<!--<button type="button" class="btn btn-primary">Save changes</button>!-->
|
||||
|
||||
|
@ -61,6 +63,12 @@
|
|||
alert("Set as Main Image");
|
||||
});
|
||||
});
|
||||
$("#deleteImage").click(function () {
|
||||
$.ajax("/g/{{ $gallery->url }}/delete?id="+$("#edit-id").val()).done(function () {
|
||||
alert("Image deleted");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
@ -43,6 +43,7 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function
|
|||
Route::get("/g/{url}/edit", [\App\Http\Controllers\GalleryController::class, 'editGalleryView']);
|
||||
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::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||
|
|
Loading…
Reference in a new issue