Working tour create,show,edit
This commit is contained in:
parent
3239f8767b
commit
06fa9a3d95
9 changed files with 240 additions and 41 deletions
|
|
@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TourController extends Controller
|
||||
{
|
||||
|
|
@ -18,6 +18,7 @@ class TourController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
error_log("Tour:index");
|
||||
$tours=Tour::all();
|
||||
return view('tour.index')->with('tours',$tours);
|
||||
}
|
||||
|
|
@ -29,7 +30,12 @@ class TourController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
error_log("Tour:create");
|
||||
$tour = new Tour;
|
||||
$tour->name="neue Tour";
|
||||
$tour->beschreibung="Tour Beschreibung";
|
||||
$tour->user_id=Auth::user()->id;
|
||||
return view('tour.create')->with('tour',$tour);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +46,32 @@ class TourController extends Controller
|
|||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
error_log("Tour:store");
|
||||
|
||||
$request->validate(
|
||||
[
|
||||
'name'=>'required|min:3',
|
||||
'beschreibung'=>'required',
|
||||
'start'=>'required',
|
||||
'deadline'=>'required',
|
||||
'user_id'=>'required',
|
||||
'bild'=>'mimes:jpg,jpeg,bmp,png,gif'
|
||||
]
|
||||
);
|
||||
|
||||
$tour=new Tour;
|
||||
$tour->name=$request->input('name');
|
||||
$tour->user_id=$request->input('user_id');
|
||||
$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);
|
||||
$tour->save();
|
||||
|
||||
error_log("Stored deadline:".$tour->deadline);
|
||||
|
||||
return redirect('/tour');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -62,7 +93,8 @@ class TourController extends Controller
|
|||
*/
|
||||
public function edit(Tour $tour)
|
||||
{
|
||||
//
|
||||
error_log("Tour:edit");
|
||||
return view('tour.edit')->with('tour',$tour);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -74,10 +106,12 @@ class TourController extends Controller
|
|||
*/
|
||||
public function update(Request $request, Tour $tour)
|
||||
{
|
||||
$tour=Tour::find($request->input('id'));
|
||||
error_log("Tour:update");
|
||||
$tour=Tour::find($request->input('tour_id'));
|
||||
|
||||
$request->validate(
|
||||
[
|
||||
'tour_id' => 'required',
|
||||
'name'=>'required|min:3',
|
||||
'beschreibung'=>'required',
|
||||
'user_id'=>'required',
|
||||
|
|
@ -108,12 +142,14 @@ class TourController extends Controller
|
|||
|
||||
$tour->name=$request->input('name');
|
||||
$tour->beschreibung=$request->input('beschreibung');
|
||||
$tour->is_cancelled=$request->input('is_cancelled');
|
||||
$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);
|
||||
|
||||
$tour->save();
|
||||
|
||||
return redirect('/member/');
|
||||
return redirect('/tour');
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -128,5 +164,4 @@ class TourController extends Controller
|
|||
//
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Tour extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = [
|
||||
'id', 'name', 'beschreibung','user_id','start','deadline'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ class CreateToursTable extends Migration
|
|||
$table->string('name');
|
||||
$table->text('beschreibung');
|
||||
$table->string('user_id');
|
||||
$table->integer('max_participants');
|
||||
$table->integer('max_participants')->default(5);
|
||||
$table->date('start')->nullable();
|
||||
$table->date('deadline')->nullable();
|
||||
$table->boolean('is_cancelled');
|
||||
$table->boolean('is_cancelled')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
BIN
motorradig/public/img/placeholder/tour128x100.jpg
Normal file
BIN
motorradig/public/img/placeholder/tour128x100.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
80
motorradig/resources/views/tour/create.blade.php
Normal file
80
motorradig/resources/views/tour/create.blade.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
@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"><h4>Tour anlegen</h4></div>
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/{{$tour->id}}" enctype="multipart/form-data">
|
||||
|
||||
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="user_id" value="{{ Auth::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:180px; text-align:left;font-size:18px;" for="deadline">Anmeldeschluss:</label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="deadline" style="font-size:16px;" name="deadline" value="{{ old('deadline') ?? $tour->deadline }}" required >
|
||||
</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>
|
||||
|
||||
|
||||
<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" 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 }}" >
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50" >{{ $tour->beschreibung }}
|
||||
</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
|
||||
81
motorradig/resources/views/tour/edit.blade.php
Normal file
81
motorradig/resources/views/tour/edit.blade.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
@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:180px; text-align:left;font-size:18px;" for="deadline">Anmeldeschluss:</label>
|
||||
<input class="mt-3 mr-2 form-control" type="text" id="deadline" style="font-size:16px;" name="deadline" value="{{ old('deadline') ?? $tour->deadline }}" required >
|
||||
</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>
|
||||
|
||||
|
||||
<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" 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 }}" >
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50" >{{ $tour->beschreibung }}
|
||||
</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
|
||||
|
|
@ -17,20 +17,6 @@
|
|||
</a>
|
||||
@endforeach
|
||||
|
||||
<!--
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
11.11.2020 - Eifeltour mit Dirk [10/10]
|
||||
<span class="badge badge-success badge-pill">FINDET STATT</span>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
01.12.2020 - Nürburgring mit Ross [8/10]
|
||||
<span class="badge badge-success badge-pill">FINDET STATT</span>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
15.12.2020 - Unterbacher See mit Torsten [1/10]
|
||||
<span class="badge badge-danger badge-pill">GECANCELT</span>
|
||||
</li>
|
||||
-->
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
@ -39,7 +25,7 @@
|
|||
</div>
|
||||
@if(Auth::user()->role=="ADMIN" or Auth::user()->rolde=="MEMBER")
|
||||
<div class="container text-primary">
|
||||
<button type="submit" class="btn btn-danger col-2 mt-2 ">Neue Tour anlegen</button>
|
||||
<a href="/tour/create" class="btn btn-danger col-2 mt-2 ">Neue Tour anlegen</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
|
|
|||
|
|
@ -9,39 +9,54 @@
|
|||
|
||||
<div class="card-body">
|
||||
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="/tour/store" enctype="multipart/form-data">
|
||||
<form style="background-color: #fff;" class="text-dark" method="post" action="" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<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 >
|
||||
<input class="mt-3 mr-2 form-control input-sm" 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 }}" required >
|
||||
<input class="mt-3 mr-2 form-control input-sm" 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-3" 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:10px;" name="start" value="{{ old('anmeldeschluss') ?? $tour->deadline }}" required >
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
@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="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 }}" required >
|
||||
<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">
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50">{{ $tour->beschreibung }}
|
||||
<textarea class="col-12" name="beschreibung" rows="10" cols="50" readonly>{{ $tour->beschreibung }}
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-success col-2 mb-2 float-right mr-2">Ok</button>
|
||||
<button type="submit" class="btn btn-danger col-2 mb-2 float-right mr-2">Teilnehmen</button>
|
||||
<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>
|
||||
|
||||
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@
|
|||
|
||||
@if(file_exists (public_path ('img/user/'.$user->id.'.jpg')))
|
||||
<!--File exists -->
|
||||
<a href="/img/user/{{$user->id}}_gross.jpg" data-lightbox="{{$user->id}}_gross.jpg" data-title="{{ $user->name }}">
|
||||
<img src="/img/user/{{$user->id}}.jpg" class="mt-3 ml-3" >
|
||||
</a>
|
||||
@else
|
||||
<img src="/img/placeholder/user64x96.jpg" class="mt-3 ml-3" >
|
||||
@endif
|
||||
<a href="/img/user/{{$user->id}}_gross.jpg" data-lightbox="{{$user->id}}_gross.jpg" data-title="{{ $user->name }}">
|
||||
<img src="/img/user/{{$user->id}}.jpg" class="mt-3 ml-3" >
|
||||
</a>
|
||||
@else
|
||||
<img src="/img/placeholder/user64x96.jpg" class="mt-3 ml-3" >
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue