diff --git a/motorradig/app/Http/Controllers/GalleryController.php b/motorradig/app/Http/Controllers/GalleryController.php index a04b6e2..6dfb407 100644 --- a/motorradig/app/Http/Controllers/GalleryController.php +++ b/motorradig/app/Http/Controllers/GalleryController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Gallery; use Illuminate\Http\Request; +use Auth; class GalleryController extends Controller { @@ -12,10 +13,6 @@ class GalleryController extends Controller * * @return \Illuminate\Http\Response */ - public function index() - { - // - } /** * Show the form for creating a new resource. @@ -44,9 +41,15 @@ class GalleryController extends Controller * @param \App\Gallery $gallery * @return \Illuminate\Http\Response */ - public function show(Gallery $gallery) - { - // + public function show($tour_id) + { + //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'); + } + + + return redirect('/tour/index_old'); } /** @@ -55,7 +58,7 @@ class GalleryController extends Controller * @param \App\Gallery $gallery * @return \Illuminate\Http\Response */ - public function edit(Gallery $gallery) + public function edit($tour_id) { // } @@ -67,7 +70,7 @@ class GalleryController extends Controller * @param \App\Gallery $gallery * @return \Illuminate\Http\Response */ - public function update(Request $request, Gallery $gallery) + public function update(Request $request, $tour_id) { // } @@ -78,7 +81,7 @@ class GalleryController extends Controller * @param \App\Gallery $gallery * @return \Illuminate\Http\Response */ - public function destroy(Gallery $gallery) + public function destroy($tour_id) { // } diff --git a/motorradig/app/User.php b/motorradig/app/User.php index 64ebd96..0db1a88 100644 --- a/motorradig/app/User.php +++ b/motorradig/app/User.php @@ -39,10 +39,7 @@ public static function has_tour($tour_id, $user_id) { -// $tour=Tour::find($tour_id); -// $user=User::first($user_id); - $booking = Booking::where('tour_id', $tour_id)->where('user_id', $user_id); - if ($booking) return true; - return false; + $booking = Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->get(); + return $booking->count() > 0; } } diff --git a/motorradig/resources/views/tour/gallery/show.blade.php b/motorradig/resources/views/tour/gallery/show.blade.php new file mode 100644 index 0000000..235fc1a --- /dev/null +++ b/motorradig/resources/views/tour/gallery/show.blade.php @@ -0,0 +1,14 @@ +@extends('layouts.app') + +@section('content') +
+

Galerie

+ +
+ +
+ +
+@endsection diff --git a/motorradig/resources/views/tour/index_old.blade.php b/motorradig/resources/views/tour/index_old.blade.php index 1876cdb..ca73621 100644 --- a/motorradig/resources/views/tour/index_old.blade.php +++ b/motorradig/resources/views/tour/index_old.blade.php @@ -18,7 +18,7 @@
  • {{ $tour->start }} - {{ $tour->name }} [{{$participantCount[$tour->id]}}/{{$tour->max_participants}}] - (Bilder) + (Galerie) @if(App\Tour::has_participant($tour->id, Auth::user()->id)==true) @endif diff --git a/motorradig/routes/web.php b/motorradig/routes/web.php index abc1551..f43303b 100644 --- a/motorradig/routes/web.php +++ b/motorradig/routes/web.php @@ -63,6 +63,8 @@ Route::get('/img_storage/{category}/{imageName}', 'ImageController@getImage'); // no middleware auth needed, its checked in Controller + Route::get('/tour/gallery/{gallery_id}', 'GalleryController@show'); // no middleware auth needed, its checked in Controller + Auth::routes(); /* Cache clearing on remote server */