Teilnehmeranzahl in Tourenliste anzeigen, Teilnahme, Absage, Admin-Absage
This commit is contained in:
parent
2f0a54ed77
commit
79b3720e8f
9 changed files with 100 additions and 53 deletions
|
|
@ -4,11 +4,13 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Tour;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TourController extends Controller
|
||||
{
|
||||
|
|
@ -21,21 +23,16 @@ class TourController extends Controller
|
|||
{
|
||||
error_log("Tour:index");
|
||||
$tours=Tour::all();
|
||||
return view('tour.index')->with('tours',$tours);
|
||||
}
|
||||
|
||||
|
||||
public function index_bookings($tour_id)
|
||||
{
|
||||
$tour=Tour::find($tour_id);
|
||||
$bookings=array();
|
||||
foreach($tour->getBookings($tour_id) as $booking) {
|
||||
array_push($bookings,$booking);
|
||||
$participantCount=array();
|
||||
foreach($tours as $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
$participantCount[$tour->id] = $result[0]->cnt;
|
||||
}
|
||||
error_log("Tour:index_bookings, tour_id=".$tour->id);
|
||||
return view('tour.index_bookings')->with('tour',$tour)->with('bookings',$bookings);
|
||||
return view('tour.index')->with('tours',$tours)->with('participantCount',$participantCount);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
|
|
@ -96,7 +93,18 @@ class TourController extends Controller
|
|||
*/
|
||||
public function show(Tour $tour)
|
||||
{
|
||||
return view('tour.show')->with('tour',$tour);
|
||||
$creator = User::find($tour->user_id);
|
||||
$bookings = Booking::where('tour_id',$tour->id)->get();
|
||||
$users = array();
|
||||
foreach($bookings as $booking) {
|
||||
$user=User::find($booking->user_id);
|
||||
array_push($users, $user);
|
||||
}
|
||||
return view('tour.show')
|
||||
->with('tour',$tour)
|
||||
->with('users', $users)
|
||||
->with('creator', $creator);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -181,7 +189,7 @@ class TourController extends Controller
|
|||
public function join($tour_id) {
|
||||
$user=Auth::user();
|
||||
Tour::join($tour_id,$user->id);
|
||||
return redirect('/tour');
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
|
||||
public function cancelBooking($tour_id) {
|
||||
|
|
@ -190,4 +198,12 @@ class TourController extends Controller
|
|||
return redirect('/tour');
|
||||
}
|
||||
|
||||
public function cancelBookingAdmin($tour_id, $user_id) {
|
||||
$user=Auth::user();
|
||||
if (Auth::user()->role == "ADMIN") {
|
||||
Booking::where('tour_id', $tour_id)->where('user_id', $user_id)->delete();
|
||||
}
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ class UserController extends Controller
|
|||
$user->mobile=$request->input('mobile');
|
||||
$user->save();
|
||||
|
||||
error_log("User role: ".$user->role);
|
||||
|
||||
return redirect('/member/');
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use Carbon\Carbon;
|
||||
class BookingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
|
||||
{{ $tour->start }} - {{ $tour->name }} [?/?]
|
||||
{{ $tour->start }} - {{ $tour->name }} [{{$participantCount[$tour->id]}}/{{$tour->max_participants}}]
|
||||
|
||||
@if(App\Tour::has_participant($tour->id, Auth::user()->id)==true)
|
||||
<i class="fas fa-biking"></i>
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container text-center text-light mt-5">
|
||||
<h1 class="text-center">Teilnehmer</h1>
|
||||
|
||||
<div class="container text-primary">
|
||||
.<ul class="list-group offset-2 col-8">
|
||||
@foreach($bookings as $booking)
|
||||
<a href="/tour/{{$tour->id}}">
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
{{ $tour->start }} - {{ $tour->name }} [?/?]
|
||||
<span class="badge {{ $tour->status=="FINDET STATT" ? "badge-success" : "badge-danger" }} badge-pill">{{ $tour->status }}</span>
|
||||
</li>
|
||||
</a>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@if(Auth::user()->role=="ADMIN" or Auth::user()->rolde=="MEMBER")
|
||||
<div class="container text-primary">
|
||||
<a href="/tour/create" class="btn btn-danger col-2 mt-2 ">Neue Tour anlegen</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<div class="row justify-content-center">
|
||||
<div class="col-md-8 mt-2">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">{{ $tour->name }}</div>
|
||||
<div class="card-header"><h5>{{ $tour->name }}</h5></div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
|
|
@ -23,6 +23,11 @@
|
|||
<input class="mr-1 form-control" type="text" id="start" name="start" value="{{ old('start') ?? $tour->start }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="mt-1" style="display:flex;">
|
||||
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="creator">Veranstalter:</label>
|
||||
<input class="mr-1 form-control" type="text" id="creator" name="creator" value="{{ old('creator') ?? $creator->name }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="mt-1" style="display:flex;">
|
||||
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Anmeldeschluss:</label>
|
||||
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="start" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
|
||||
|
|
@ -74,13 +79,64 @@
|
|||
<a href="/tour/{{$tour->id}}/cancelBooking" type="submit" class="btn btn-danger col-3 mb-2 float-right mr-2">Absagen</a>
|
||||
@endif
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 mt-2">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><h5>Teilnehmer</h5></div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<ul>
|
||||
@foreach($users as $user)
|
||||
<li>{{ $user->name }}
|
||||
@if(Auth::user()->role=="ADMIN")
|
||||
<a href="/tour/{{$tour->id}}/cancelBookingAdmin/{{$user->id}}" class="text-primary">(X)</a>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Button trigger modal demo
|
||||
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
|
||||
Launch demo modal
|
||||
</button>
|
||||
|
||||
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Teilnehmer entfernen</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Sind sie sicher ??
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" onclick="alert('LÖSCHEN'); return false;" data-dismiss="modal" class="btn btn-danger">Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@
|
|||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name"><h4>Name:</h4></label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="name" style="font-size:20px;" name="name" value="{{ old('name') ?? $user->name }}" required >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="mobile" ><h4>Telefonnummer:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="mobile" style="font-size:20px;" name="mobile" value="{{ old('mobile') ?? $user->mobile }}" required >
|
||||
</div>
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name" ><h4>EMail:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="lastname" style="font-size:20px;" name="email" value="{{ old('email') ?? $user->email }}" required >
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@
|
|||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name"><h4>Name:</h4></label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="name" style="font-size:20px;" name="name" value="{{ old('name') ?? $user->name }}" required >
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="name" style="font-size:20px;" name="name" value="{{ old('name') ?? $user->name }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="email" ><h4>EMail:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="email" style="font-size:20px;" name="email" value="{{ old('email') ?? $user->email }}" required >
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="email" style="font-size:20px;" name="email" value="{{ old('email') ?? $user->email }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="name" ><h4>Telefon:</h4></label>
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="mobile" style="font-size:20px;" name="mobile" value="{{ old('mobile') ?? $user->mobile }}" required >
|
||||
<input type="text" class="mt-3 mr-2 form-control" id="mobile" style="font-size:20px;" name="mobile" value="{{ old('mobile') ?? $user->mobile }}" readonly >
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ Route::post('/admin/store_activities', 'AdminController@store_activities');
|
|||
Route::resource('/tour', TourController::class);
|
||||
Route::get('/tour/{tour_id}/join', 'TourController@join');
|
||||
Route::get('/tour/{tour_id}/cancelBooking', 'TourController@cancelBooking');
|
||||
Route::get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', 'TourController@cancelBookingAdmin');
|
||||
|
||||
Auth::routes();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue