diff --git a/motorradig/app/Gallery.php b/motorradig/app/Gallery.php deleted file mode 100644 index d38db2f..0000000 --- a/motorradig/app/Gallery.php +++ /dev/null @@ -1,10 +0,0 @@ -role . " id:" . \Auth::id() . " has_tour:" . Auth::user()->has_tour($tour_id, \Auth::id())); - if(Auth::user()->role=="ADMIN" or Auth::user()->has_tour($tour_id, \Auth::id()) ) { - return view('tour/gallery/show')->with("tour_id",$tour_id); + if(Auth::user()->role=="ADMIN" or Auth::user()->has_tour($tour_id, \Auth::id()) ) { + + $imagelist_orig = Storage::disk('img_storage')->files("tour-$tour_id"); + $imagelist=[]; + foreach($imagelist_orig as $image) { + $arr = explode("/", $image); + $image = end($arr); + array_push($imagelist, $image); + } + + //dd($imagelist); + return view('tour/gallery/show')->with("tour_id",$tour_id)->with("imagelist",$imagelist); } + /* + tour-1 + 2023-04-24-ref1png.jpg + */ return redirect('/tour/index_old'); } @@ -65,7 +83,7 @@ class GalleryController extends Controller // } - public function store(Request $request, Tour $tour) { + public function store(Request $request, $tour_id) { $request->validate( [ 'files' => 'required' @@ -74,7 +92,74 @@ class GalleryController extends Controller //$filelist = join(', ', $request->files); //dd($filelist); $filelist=""; - //foreach($request->files as $filename) { $filelist = $filelist + $filename; } - dd($request->files); + + /* + foreach($request->files as $file) { + Log::info("File:"); + Log::info($file); + foreach($file as $entry) { + Log::info($entry); + } + */ + //Log::info($request->files[0]) ; + + + //Log::info($file->getClientOriginalName()); + //Log::info("####################################"); + + //Log::info($file->get("originalName")); + //$filelist = $filelist . "," . $file->originalName; + + + + foreach($request->file('files') as $file) + { + //$name = time().'.'.$file->extension(); + //$file->move(public_path().'/files/', $name); + //$data[] = $name; + //Log::info($name); + + $orig_filename = $file->getClientOriginalName(); + $this->storeImage($file,"tour_$tour_id", $orig_filename); + Log::info($orig_filename); + } + //$file= new File(); + //$file->filenames=json_encode($data); + //$file->save(); + return redirect('/tour/index_old'); } + + /////////////////////////////////////////////////////////////////////////// + + private function storeImage($bild, $category, $name) { + $cat=Str::slug($category); + $name=Str::slug($name); + + $dirPath = storage_path() . "/img_storage/$cat"; + if (!file_exists($dirPath)) { + mkdir($dirPath, 0777, true); + } + + $bild = Image::make($bild); + $breite = $bild->width(); + $hoehe = $bild->height(); + if ($breite > $hoehe) { + Image::make($bild) + ->widen(1200) + ->save("$dirPath/$name"."_gross.jpg"); + Image::make($bild) + ->widen(128) + ->save("$dirPath/$name".".jpg"); + } else { + Image::make($bild) + ->heighten(900) + ->save("$dirPath/$name"."_gross.jpg");; + Image::make($bild) + ->widen(192) + ->save("$dirPath/$name".".jpg"); + } + Log::info("Image saved as $dirPath/$name" . '_gross.jpg'); + Log::info("Image saved as $dirPath/$name" . '.jpg'); + } + } diff --git a/motorradig/app/Http/Controllers/GalleryItemController.php b/motorradig/app/Http/Controllers/GalleryItemController.php deleted file mode 100644 index 6d849a2..0000000 --- a/motorradig/app/Http/Controllers/GalleryItemController.php +++ /dev/null @@ -1,85 +0,0 @@ -id(); - $table->string('name'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('galleries'); - } -} diff --git a/motorradig/database/migrations/2020_10_15_065431_create_gallery_items_table.php b/motorradig/database/migrations/2020_10_15_065431_create_gallery_items_table.php deleted file mode 100644 index 4d4416e..0000000 --- a/motorradig/database/migrations/2020_10_15_065431_create_gallery_items_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->integer('gallery_id'); - $table->integer('order')->default(0); - $table->string('filename'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('gallery_items'); - } -} diff --git a/motorradig/resources/views/tour/gallery/show.blade.php b/motorradig/resources/views/tour/gallery/show.blade.php index ed6bcac..d18e60c 100644 --- a/motorradig/resources/views/tour/gallery/show.blade.php +++ b/motorradig/resources/views/tour/gallery/show.blade.php @@ -8,7 +8,10 @@