View alter Touren, TourSeeder mit alter Tour, Verlinkung
This commit is contained in:
parent
79b3720e8f
commit
e6f3767e33
8 changed files with 238 additions and 10 deletions
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Tour;
|
||||
use App\Booking;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
@ -22,7 +23,7 @@ class TourController extends Controller
|
|||
public function index()
|
||||
{
|
||||
error_log("Tour:index");
|
||||
$tours=Tour::all();
|
||||
$tours=Tour::where('start','>',Carbon::now())->get();
|
||||
$participantCount=array();
|
||||
foreach($tours as $tour) {
|
||||
$result = DB::select('select count(*) as cnt from bookings where tour_id=?', [$tour->id]);
|
||||
|
|
@ -31,6 +32,19 @@ class TourController extends Controller
|
|||
return view('tour.index')->with('tours',$tours)->with('participantCount',$participantCount);
|
||||
}
|
||||
|
||||
public function index_old()
|
||||
{
|
||||
error_log("Tour:index_old");
|
||||
$tours=Tour::where('start','<',Carbon::now())->get();
|
||||
$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;
|
||||
}
|
||||
return view('tour.index_old')->with('tours',$tours)->with('participantCount',$participantCount);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
|
@ -206,4 +220,5 @@ class TourController extends Controller
|
|||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,4 +44,10 @@ class Tour extends Model
|
|||
public static function cancel($tour_id, $user_id) {
|
||||
Booking::where('tour_id',$tour_id)->where('user_id',$user_id)->delete();
|
||||
}
|
||||
|
||||
public static function is_over($tour_id) {
|
||||
$tour = Tour::find($tour_id);
|
||||
if ($tour->start < Carbon::now()) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,23 @@ class TourSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('tours')->insert([
|
||||
'name' => 'Moseltour',
|
||||
'user_id' => 3,
|
||||
'start' => Carbon::parse('2019-06-11'),
|
||||
'deadline' => Carbon::parse('2019-05-30'),
|
||||
'is_cancelled' => false,
|
||||
'max_participants' => 8,
|
||||
'beschreibung' => 'Erster Versuch einer Moseltour.'
|
||||
]);
|
||||
|
||||
DB::table('tours')->insert([
|
||||
'name' => 'Eifeltour1',
|
||||
'user_id' => 3,
|
||||
'start' => Carbon::parse('2020-11-11'),
|
||||
'deadline' => Carbon::parse('2020-11-01'),
|
||||
'is_cancelled' => false,
|
||||
'max_participants' => 7,
|
||||
'beschreibung' => 'Hier kann ein sehr langer Text stehen.'
|
||||
]);
|
||||
|
||||
|
|
@ -27,6 +38,7 @@ class TourSeeder extends Seeder
|
|||
'beschreibung' => 'Hier kann ein sehr langer Text stehen.',
|
||||
'start' => Carbon::parse('2020-12-01'),
|
||||
'deadline' => Carbon::parse('2020-11-02'),
|
||||
'max_participants' => 6,
|
||||
'is_cancelled' => false,
|
||||
]);
|
||||
|
||||
|
|
@ -36,10 +48,9 @@ class TourSeeder extends Seeder
|
|||
'beschreibung' => 'Hier kann ein wirklich sehr langer Text stehen. <p> </p> Es sind auch mehrere Abschnitte möglich.',
|
||||
'start' => Carbon::parse('2020-12-15'),
|
||||
'deadline' => Carbon::parse('2020-11-15'),
|
||||
'max_participants' => 5,
|
||||
'is_cancelled' => true
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,20 @@
|
|||
|
||||
@section('content')
|
||||
<div class="container text-center text-light mt-5">
|
||||
<h1 class="text-center">Tourenplan</h1>
|
||||
<a href="/pdf/tourenplan.pdf" class="text-center text-light">Download</a>
|
||||
<h1 class="text-center">Tourenplan: aktuelle Touren</h1>
|
||||
|
||||
<div class="container text-primary mb-3">
|
||||
<span class="offset-1 col-4 float-left mb-3"><a class="btn btn-success" href="/tour/index_old" class="text-center text-light"><h3>Alte Touren</h3></a></span>
|
||||
<span class="offset-1"><a href="/pdf/tourenplan.pdf" class="btn btn-success"><h3>Download</h3></a></span>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="row mb-2">
|
||||
|
||||
<span class="offset-1 col-4 float-left "><a class="btn btn-success" href="/pdf/tourenplan.pdf" class="text-center text-light"><h3>Alte Touren</h3></a></span>
|
||||
<span class="offset-3 float-right"><a href="/pdf/tourenplan.pdf" class="text-center text-light"><h3>Download</h3></a></span>
|
||||
</div>
|
||||
-->
|
||||
|
||||
|
||||
<div class="container text-primary" style="display:flex">
|
||||
|
|
@ -26,14 +38,12 @@
|
|||
@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>
|
||||
<a href="/tour/create" class="btn btn-danger col-3 mt-2 "><h3>Neue Tour anlegen</h3></a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
|
|
|||
38
motorradig/resources/views/tour/index_old.blade.php
Normal file
38
motorradig/resources/views/tour/index_old.blade.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container text-center text-light mt-5">
|
||||
<h1 class="text-center">Tourenplan: alte Touren</h1>
|
||||
|
||||
<div class="container text-primary mb-3">
|
||||
<span class="offset-1 col-4 float-left mb-3"><a class="btn btn-success" href="/tour" class="text-center text-light"><h3>Aktuelle Touren</h3></a></span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container text-primary" style="display:flex">
|
||||
.<ul class="list-group offset-2 col-8">
|
||||
@foreach($tours as $tour)
|
||||
|
||||
<a href="/tour/{{$tour->id}}">
|
||||
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
|
||||
{{ $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>
|
||||
@endif
|
||||
|
||||
<span class="badge {{ $tour->status=="FINDET STATT" ? "badge-success" : "badge-danger" }} badge-pill">{{ $tour->status }}</span>
|
||||
</li>
|
||||
</a>
|
||||
@endforeach
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -79,6 +79,8 @@
|
|||
<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>
|
||||
|
|
|
|||
144
motorradig/resources/views/tour/show_old.blade.php
Normal file
144
motorradig/resources/views/tour/show_old.blade.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8 mt-2">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header"><h5>{{ $tour->name }}</h5></div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="" 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" style="width:180px; text-align:left;font-size:18px;" for="name">Name:</label>
|
||||
<input class="mr-1 form-control" type="text" id="name" name="name" value="{{ old('name') ?? $tour->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">Start:</label>
|
||||
<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 >
|
||||
</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 }}">
|
||||
<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
|
||||
|
||||
<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>
|
||||
|
||||
<div class="mt-1">
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
<!-- TODO: Only if owner or admin -->
|
||||
<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>
|
||||
</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
|
||||
|
|
@ -43,7 +43,9 @@ Route::get('/admin/edit_home', 'AdminController@edit_home');
|
|||
Route::get('/admin/edit_activities', 'AdminController@edit_activities');
|
||||
Route::post('/admin/store_activities', 'AdminController@store_activities');
|
||||
|
||||
Route::get('/tour/index_old', 'TourController@index_old');
|
||||
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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue