First version of gallery
This commit is contained in:
parent
7d11a6fa1c
commit
5d6f3f1b05
14 changed files with 94 additions and 178 deletions
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gallery extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GalleryItem extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -6,6 +6,10 @@ use App\Gallery;
|
|||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use App\Tour;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GalleryController extends Controller
|
||||
{
|
||||
|
|
@ -36,9 +40,23 @@ class GalleryController extends Controller
|
|||
{
|
||||
//dd("role:" . Auth::user()->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);
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\GalleryItem;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GalleryItemController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\GalleryItem $galleryItem
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(GalleryItem $galleryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\GalleryItem $galleryItem
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(GalleryItem $galleryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\GalleryItem $galleryItem
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, GalleryItem $galleryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\GalleryItem $galleryItem
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(GalleryItem $galleryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateGalleriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('galleries', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('galleries');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateGalleryItemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('gallery_items', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,10 @@
|
|||
<h1>(Galerie Elemente)</h1>
|
||||
<div class="container text-primary" style="display:flex">
|
||||
<ul class="list-group offset-2 col-8">
|
||||
@foreach($imagelist as $image)
|
||||
<img src="/img_storage/tour-{{$tour_id}}/{{$image}}">
|
||||
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
BIN
motorradig/storage/img_storage/tour-1/2023-04-24-ref1png.jpg
Normal file
BIN
motorradig/storage/img_storage/tour-1/2023-04-24-ref1png.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
Loading…
Add table
Add a link
Reference in a new issue