Working on Tour Booking
This commit is contained in:
parent
e9f629db90
commit
30cdeab510
5 changed files with 64 additions and 25 deletions
|
|
@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class Tour extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'id', 'name', 'beschreibung','user_id','start','deadline'
|
||||
'id', 'name', 'beschreibung','user_id','start','deadline','is_cancelled', 'status'
|
||||
];
|
||||
|
||||
public static function getBookings($tour_id) {
|
||||
|
|
@ -15,4 +15,24 @@ class Tour extends Model
|
|||
$bookings=Booking::where('tour_id',$tour_id)->get();
|
||||
return $bookings;
|
||||
}
|
||||
|
||||
public static function has_participant($tour_id, $user_id) {
|
||||
$booking=Booking::where('tour_id', $tour_id)->where('user_id',$user_id)->first();
|
||||
|
||||
if($booking) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function join($tour_id,$user_id) {
|
||||
Booking::firstOrCreate(
|
||||
['tour_id',$tour_id],
|
||||
['user_id',$user_id],
|
||||
['updated_at', \Carbon::now()]
|
||||
);
|
||||
}
|
||||
|
||||
public static function leave($tour_id, $user_id) {
|
||||
Booking::where('tour_id',$tour_id)->where('user_id',$user_id)->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class CreateToursTable extends Migration
|
|||
$table->date('start')->nullable();
|
||||
$table->date('deadline')->nullable();
|
||||
$table->boolean('is_cancelled')->default(false);
|
||||
$table->string('status')->default('FINDET STATT');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class TourSeeder extends Seeder
|
|||
'name' => 'Eifeltour1',
|
||||
'user_id' => 3,
|
||||
'start' => Carbon::parse('2020-11-11'),
|
||||
'deadline' => Carbon::parse('2020-11-01'),
|
||||
'is_cancelled' => false,
|
||||
'beschreibung' => 'Hier kann ein sehr langer Text stehen.'
|
||||
]);
|
||||
|
|
@ -25,6 +26,7 @@ class TourSeeder extends Seeder
|
|||
'user_id' => 2,
|
||||
'beschreibung' => 'Hier kann ein sehr langer Text stehen.',
|
||||
'start' => Carbon::parse('2020-12-01'),
|
||||
'deadline' => Carbon::parse('2020-11-02'),
|
||||
'is_cancelled' => false,
|
||||
]);
|
||||
|
||||
|
|
@ -33,6 +35,7 @@ class TourSeeder extends Seeder
|
|||
'user_id' => 1,
|
||||
'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'),
|
||||
'is_cancelled' => true
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,20 @@
|
|||
<a href="/pdf/tourenplan.pdf" class="text-center text-light">Download</a>
|
||||
|
||||
|
||||
<div class="container text-primary">
|
||||
<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 }} [?/?]
|
||||
|
||||
@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>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="col-md-8 mt-2">
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">{{ $tour->name }}</div>
|
||||
|
||||
|
|
@ -12,27 +12,34 @@
|
|||
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<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 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 }}" readonly >
|
||||
<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="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 }}" readonly >
|
||||
<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="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="name">Anmeldeschluss:</label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="anmeldeschluss" style="font-size:16px;" name="start" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" readonly >
|
||||
<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="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-4" style="width:180px; text-align:left;font-size:18px;" for="name">Max Teilnehmer:</label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="max_participants" style="font-size:16px;" name="max_participants" value="{{ old('max_participants') ?? $tour->max_participants }}" required >
|
||||
<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 }}">
|
||||
|
|
@ -42,25 +49,25 @@
|
|||
<img src="/img/placeholder/tour128x100.jpg" class="mt-3 ml-3" >
|
||||
@endif
|
||||
|
||||
<div class="form-group" style="display:flex;">
|
||||
<label class="ml-2 mt-3" style="width:140px; text-align:left;font-size:18px;" for="name">Storniert:</label>
|
||||
<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 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="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 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="form-group">
|
||||
<div class="mt-1">
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<a href="/tour/{{$tour->id}}/edit"><div type="submit" class="btn btn-danger col-2 mb-2 float-left mr-2">Bearbeiten</div></a>
|
||||
<a href="/tour" type="submit" class="btn btn-success col-2 mb-2 float-right mr-2">Ok</a>
|
||||
<a href="#" type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Teilnehmen</a>
|
||||
<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>
|
||||
<a href="#" type="submit" class="btn btn-danger col-3 mb-2 float-right mr-2">Teilnehmen</a>
|
||||
|
||||
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue