Bericht für alte Touren schreiben

This commit is contained in:
TorstenS 2020-10-14 09:33:09 +02:00
parent e6f3767e33
commit 293c2c535f
6 changed files with 88 additions and 38 deletions

View file

@ -114,11 +114,17 @@ class TourController extends Controller
$user=User::find($booking->user_id);
array_push($users, $user);
}
if($tour->start<Carbon::now()) {
return view('tour.show_old')
->with('tour', $tour)
->with('users', $users)
->with('creator', $creator);
}
return view('tour.show')
->with('tour',$tour)
->with('tour', $tour)
->with('users', $users)
->with('creator', $creator);
}
/**
@ -130,7 +136,10 @@ class TourController extends Controller
public function edit(Tour $tour)
{
error_log("Tour:edit");
return view('tour.edit')->with('tour',$tour);
if ($tour->start<Carbon::now()) {
return view('tour.edit_old')->with('tour', $tour);
}
return view('tour.edit')->with('tour', $tour);
}
/**
@ -149,7 +158,6 @@ class TourController extends Controller
[
'tour_id' => 'required',
'name'=>'required|min:3',
'beschreibung'=>'required',
'user_id'=>'required',
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
]
@ -177,12 +185,12 @@ class TourController extends Controller
}
$tour->name=$request->input('name');
$tour->beschreibung=$request->input('beschreibung');
$tour->start=$request->input('start');
$tour->deadline=$request->input('deadline');
$tour->max_participants=$request->input('max_participants');
$tour->is_cancelled=$request->input('is_cancelled',false);
if ($request->beschreibung) $request->input('beschreibung');
if ($request->start) $tour->start=$request->input('start');
if ($request->deadline) $tour->deadline=$request->input('deadline');
if ($request->max_participants) $tour->max_participants=$request->input('max_participants');
if ($request->is_cancelled) $tour->is_cancelled=$request->input('is_cancelled',false);
if ($request->bericht) $tour->bericht=$request->bericht;
$tour->save();
return redirect('/tour');

View file

@ -22,6 +22,7 @@ class CreateToursTable extends Migration
$table->date('start')->nullable();
$table->date('deadline')->nullable();
$table->boolean('is_cancelled')->default(false);
$table->text('bericht')->nullable();
$table->string('status')->default('FINDET STATT');
$table->timestamps();
});

View file

@ -19,6 +19,7 @@ class TourSeeder extends Seeder
'deadline' => Carbon::parse('2019-05-30'),
'is_cancelled' => false,
'max_participants' => 8,
'bericht' => 'Wir hatten gutes Wetter, gute Stimmung, und alles war toll.',
'beschreibung' => 'Erster Versuch einer Moseltour.'
]);

View file

@ -0,0 +1,62 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card mt-4">
<div class="card-header">{{ $tour->name }}</div>
<div class="card-body">
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/{{$tour->id}}" enctype="multipart/form-data">
@csrf
@method('PUT')
<input type="hidden" name="tour_id" value="{{ $tour->id }}">
<input type="hidden" name="user_id" value="{{ $tour->user_id }}">
<div class="form-group" style="display:flex;">
<!-- label class="ml-2 mt-4 col-form-label col-form-label-sm" style="width:150px; text-align:left;" for="name"><h4>Name:</h4></label> -->
<label class="ml-2 mt-3 col-form-label col-form-label-sm" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
<input class="mt-3 mr-2 form-control input-sm" type="text" id="name" name="name" value="{{ old('name') ?? $tour->name }}" required >
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-3" style="width:180px; text-align:left;font-size:18px;" for="name">Start:</label>
<input class="mt-3 mr-2 form-control input-sm" type="text" id="start" name="start" value="{{ old('start') ?? $tour->start }}" required >
</div>
<div class="form-group" style="display:flex;">
<label class="ml-2 mt-4" style="width:150px; text-align:left;" for="bild" ><h4>Bild:</h4></label>
@if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg')))
<!--File exists -->
<a href="/img/user/{{$tour->id}}_gross.jpg" data-lightbox="{{$tour->id}}_gross.jpg" data-title="{{ $tour->name }}">
<img src="/img/user/{{$tour->id}}.jpg" class="mt-3 ml-3" >
</a>
@else
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3" >
@endif
<input type="file" class="mt-3 mr-2 form-control" id="bild" style="font-size:20px;" name="bild" value="" >
</div>
<div class="form-group">
<label class="ml-2 mt-3" style="width:140px; text-align:left;font-size:18px;" for="name">Bericht:</label>
<textarea class="col-12" name="bericht" rows="10" cols="50" >{{ $tour->bericht }}
</textarea>
</div>
<a href="/tour/{{$tour->id}}"><div type="submit" class="btn btn-success col-2 mb-2 float-right mr-2">Abbrechen</div></a>
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Speichern</button>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection

View file

@ -59,11 +59,6 @@
<input class="mr-1 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="mt-1" style="display:flex;">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="name">Teilnehmer:</label>
<a href="#" class="mr-1 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="mt-1">
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
</textarea>

View file

@ -33,18 +33,12 @@
<input class="mr-1 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="start" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
</div>
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:180px; text-align:left;font-size:18px;" for="name">Max Teilnehmer:</label>
<input class="mr-1 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" value="{{ old('max_participants') ?? $tour->max_participants }}" required >
</div>
@if(App\Tour::has_participant($tour->id, Auth::user()->id))
<label>Du nimmst teil.</label>
@else
<label>Du nimmst nicht teil.</label>
@endif
@if(file_exists (public_path ('img/tour/'.$tour->id.'.jpg')))
<!--File exists -->
<a href="/img/tour/{{$tour->id}}_gross.jpg" data-lightbox="{{$tour->id}}_gross.jpg" data-title="{{ $tour->name }}">
@ -54,18 +48,15 @@
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3" >
@endif
<div class="mt-1" style="display:flex;">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="name">Storniert:</label>
<input class="mr-1 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="mt-1" style="display:flex;">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="name">Teilnehmer:</label>
<a href="#" class="mr-1 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 class="mt-1">
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="name">Beschreibung:</label>
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
</textarea>
</div>
<div class="mt-1">
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
<label class="ml-2" style="width:140px; text-align:left;font-size:18px;" for="name">Bericht:</label>
<textarea class="col-12" name="bericht" rows="10" cols="50" readonly>{{ $tour->bericht }}
</textarea>
</div>
@ -73,14 +64,6 @@
<a href="/tour/{{$tour->id}}/edit"><div type="submit" class="btn btn-danger col-3 mb-2 float-left mr-2">Bearbeiten</div></a>
<a href="/tour" type="submit" class="btn btn-success col-3 mb-2 float-right mr-2">Ok</a>
@if(!App\Tour::has_participant($tour->id, Auth::user()->id))
<a href="/tour/{{$tour->id}}/join" type="submit" class="btn btn-danger col-3 mb-2 float-right mr-2">Teilnehmen</a>
@else
<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>