Started work on Tour Booking

This commit is contained in:
TorstenS 2020-10-06 08:54:14 +02:00
parent 06fa9a3d95
commit e9f629db90
5 changed files with 54 additions and 85 deletions

View file

@ -1,85 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Booking;
use Illuminate\Http\Request;
class BookingController 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\Booking $booking
* @return \Illuminate\Http\Response
*/
public function show(Booking $booking)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
*/
public function edit(Booking $booking)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Booking $booking)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Booking $booking
* @return \Illuminate\Http\Response
*/
public function destroy(Booking $booking)
{
//
}
}

View file

@ -23,6 +23,19 @@ class TourController extends Controller
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);
}
error_log("Tour:index_bookings, tour_id=".$tour->id);
return view('tour.index_bookings')->with('tour',$tour)->with('bookings',$bookings);
}
/**
* Show the form for creating a new resource.
*

View file

@ -9,4 +9,10 @@ class Tour extends Model
protected $fillable = [
'id', 'name', 'beschreibung','user_id','start','deadline'
];
public static function getBookings($tour_id) {
error_log("getBookings for tour_id: ".$tour_id);
$bookings=Booking::where('tour_id',$tour_id)->get();
return $bookings;
}
}

View file

@ -0,0 +1,31 @@
@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

View file

@ -47,6 +47,10 @@
<input class="mt-3 mr-2 form-control" type="checkbox" id="anmeldeschluss" style="font-size:10px;width:20px;" name="anmeldeschluss" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" onclick="return false;" >
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3" style="width:140px; text-align:left;font-size:18px;" for="name">Teilnehmer:</label>
<a href="#" class="mt-3 mr-2 form-control" id="max_participants" style="font-size:16px;width:36px;" name="max_participants" onclick="return false;">{{ old('max_participants') ?? count(\App\Tour::getBookings($tour->id)) }}</a>
</div>
<div class="form-group">
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}