Photo and album deletion functionnal

beta
anulax1225 ago%!(EXTRA string=3 months)
parent 2ba82e9c16
commit 2defe85c00
  1. 7
      app/Http/Controllers/AlbumController.php
  2. 1
      app/Http/Controllers/PhotoController.php
  3. 7
      resources/js/Pages/Album/Partials/Show.vue

@ -126,6 +126,11 @@ public function addPhotos(Request $request)
*/
public function destroy(string $id)
{
//
$album = Album::where("uuid", $id)->first();
if(!$album) redirect()->back()->withErrors(["uuid" => "Album introuvable" ]);
$album->photos()->detach();
Storage::disk("s3")->delete($album->path);
$album->delete();
return redirect(route("album.index"))->with(["message" => "Album supprimée avec success"]);
}
}

@ -132,6 +132,7 @@ public function destroy(string $id)
$photo = Photo::where("uuid", $id)->first();
if(!$photo) redirect()->back()->withErrors(["uuid" => "Photo introuvable" ]);
$photo->albums()->detach();
Storage::disk("s3")->delete($photo->path);
$photo->delete();
return redirect(route("photo.index"))->with(["message" => "Photo supprimée avec success"]);
}

@ -31,9 +31,10 @@ const photoState = reactive({ edit: false });
const emits = defineEmits(["full-screen"]);
const deletePhoto = async () => {
if(confirm("Voulez-vous vraiment supprimé cette photo")){
form.delete("/photo/" + props.album.uuid, {
const deleteAlbum = async (e) => {
Utils.Prevent(e);
if(confirm("Voulez-vous vraiment supprimé cette album")){
form.delete(route("album.destroy", props.album.uuid), {
headers: {
"X-CSRF-Token": document.querySelector('input[name=_token]').value,
}

Loading…
Cancel
Save