Delete(Move) Gallery Images
This commit is contained in:
parent
6d67a5876b
commit
4b0ab47db7
7 changed files with 39 additions and 7 deletions
|
|
@ -136,13 +136,31 @@ class GalleryController extends Controller
|
|||
//$file= new File();
|
||||
//$file->filenames=json_encode($data);
|
||||
//$file->save();
|
||||
return redirect('/tour/index_old');
|
||||
return redirect("/tour/gallery/$tour_id");
|
||||
}
|
||||
|
||||
public function delete_image($tour_id, $image_name) {
|
||||
$image_name = explode(".", $image_name)[0];
|
||||
$files = [$image_name . ".jpg" , $image_name . "_gross.jpg"];
|
||||
$sourceDir = storage_path() . "/img_storage/tour-$tour_id";
|
||||
$targetDir = storage_path() . "/img_storage/tour-$tour_id-DELETED";
|
||||
|
||||
if (!file_exists($targetDir)) {
|
||||
mkdir($targetDir, 0777, true);
|
||||
}
|
||||
|
||||
foreach($files as $file) {
|
||||
rename("$sourceDir/$file", "$targetDir/$file");
|
||||
}
|
||||
return redirect("/tour/gallery/$tour_id");
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private function storeImage($bild, $category, $name) {
|
||||
$cat=Str::slug($category);
|
||||
|
||||
$name = explode(".",$name)[0];
|
||||
$name=Str::slug($name);
|
||||
|
||||
$dirPath = storage_path() . "/img_storage/$cat";
|
||||
|
|
|
|||
|
|
@ -6,15 +6,27 @@
|
|||
<h1>{{$tour_name}}</h1>
|
||||
|
||||
<div class="container text-primary" style="display:flex">
|
||||
<ul class="list-group offset-2 col-8" style="display:inline">
|
||||
<!-- <ul class="list-group offset-2 col-8" style="display:inline"> -->
|
||||
<ul class="list-group offset-2 col-8" style="display:flex; flex-direction: row;">
|
||||
@foreach($imagelist as $image)
|
||||
<label style="display:flex; flex-direction: column;">
|
||||
<a style="display: inline;" href="/img_storage/tour-{{$tour_id}}/{{$image}}_gross.jpg" data-lightbox="/img_storage/tour-{{$tour_id}}/{{$image}}_gross.jpg" data-title="{{$image}}">
|
||||
<img class="mt-3 ml-3" src="/img_storage/tour-{{$tour_id}}/{{$image}}.jpg">
|
||||
</a>
|
||||
|
||||
@if(Auth::user()->role=="ADMIN")
|
||||
<a href="/tour/gallery/{{$tour_id}}/delete_image/{{$image}}.jpg" style="color:red;"><span data-toggle="tooltip" title="Löschen">X</a>
|
||||
@endif
|
||||
</label>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
<a href="#">
|
||||
<span data-toggle="tooltip" title="I love you">Try
|
||||
|
||||
</span> Me
|
||||
</a>
|
||||
|
||||
|
||||
<h1 style="color:white;">Hochladen</h1>
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/gallery/{{$tour_id}}" enctype="multipart/form-data">
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@
|
|||
|
||||
Route::get('/tour/gallery/{gallery_id}', 'GalleryController@show'); // no middleware auth needed, its checked in Controller
|
||||
Route::post('/tour/gallery/{gallery_id}', 'GalleryController@store');
|
||||
Route::get('/tour/gallery/{gallery_id}/delete_image/{imageName}', 'GalleryController@delete_image');
|
||||
|
||||
|
||||
Auth::routes();
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 206 KiB After Width: | Height: | Size: 206 KiB |
Loading…
Add table
Add a link
Reference in a new issue