Added Methods, routes and Views for VeranstaltungController
This commit is contained in:
parent
46e092f04f
commit
1deb0f59fc
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Veranstaltung;
|
use App\Veranstaltung;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
class VeranstaltungController extends Controller
|
class VeranstaltungController extends Controller
|
||||||
{
|
{
|
||||||
@ -24,8 +25,11 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
$v = new Veranstaltung();
|
||||||
|
$v->beginn = \Carbon\Carbon::today();
|
||||||
|
|
||||||
return view ('veranstaltung.create', ['model' =>
|
return view ('veranstaltung.create', ['model' =>
|
||||||
new Veranstaltung()]);
|
$v]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,7 +40,21 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
$input = $request->input();
|
||||||
|
$v = new Veranstaltung();
|
||||||
|
$v->name = $input['name'];
|
||||||
|
$v->gaeste = (int)$input['gaeste'];
|
||||||
|
$v->beginn = new \Carbon\Carbon($input['beginn']);
|
||||||
|
if ($input['ende']) {
|
||||||
|
$v->ende = new \Carbon\Carbon($input['ende']);
|
||||||
|
}
|
||||||
|
$v->hinweise = $input['hinweise'] ?: "";
|
||||||
|
|
||||||
|
if ($v->save()) {
|
||||||
|
return redirect()->route('veranstaltung.show', [$v] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +65,8 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Veranstaltung $veranstaltung)
|
public function show(Veranstaltung $veranstaltung)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
return view('veranstaltung.show', $veranstaltung);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +77,7 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(Veranstaltung $veranstaltung)
|
public function edit(Veranstaltung $veranstaltung)
|
||||||
{
|
{
|
||||||
//
|
return view('veranstaltung.edit', $veranstaltung);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +89,21 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, Veranstaltung $veranstaltung)
|
public function update(Request $request, Veranstaltung $veranstaltung)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
|
if ($request->isMethod('put')) {
|
||||||
|
$i = $request->input();
|
||||||
|
$veranstaltung->gaeste = $i['gaeste'];
|
||||||
|
$veranstaltung->name = $i['name'];
|
||||||
|
$veranstaltung->hinweise = $i['hinweise'];
|
||||||
|
$veranstaltung->beginn = new \Carbon\Carbon($i['beginn']);
|
||||||
|
$veranstaltung->ende = $i['ende'] ? new \Carbon\Carbon($i['ende']) : null;
|
||||||
|
if($veranstaltung->save()){
|
||||||
|
return redirect()->route('veranstaltung.show', [$veranstaltung]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return response()->json($veranstaltung);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,6 +114,13 @@ class VeranstaltungController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Veranstaltung $veranstaltung)
|
public function destroy(Veranstaltung $veranstaltung)
|
||||||
{
|
{
|
||||||
//
|
$veranstaltung->delete();
|
||||||
|
|
||||||
|
return redirect()->route('veranstaltung.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enter(Request $request, Veranstaltung $veranstaltung)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ namespace App\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@ -15,6 +16,9 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
|
date_default_timezone_set("Europe/Berlin");
|
||||||
|
setlocale(LC_TIME, "German");
|
||||||
|
Carbon::setLocale('de');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -7,5 +7,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
class Veranstaltung extends Model
|
class Veranstaltung extends Model
|
||||||
{
|
{
|
||||||
protected $table = "veranstaltungen";
|
protected $table = "veranstaltungen";
|
||||||
//
|
|
||||||
|
protected $fillable = ['name','beginn','ende','geaste','hinweise'];
|
||||||
|
|
||||||
|
protected $dates = ['beginn', 'ende'];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,10 +10,11 @@
|
|||||||
<body>
|
<body>
|
||||||
@section('navbar')
|
@section('navbar')
|
||||||
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
|
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
|
||||||
|
<div class="">
|
||||||
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="#">Navbar</a>
|
<a class="navbar-brand" href="#">Dienstplanung</a>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav mr-auto">
|
<ul class="navbar-nav mr-auto">
|
||||||
@ -32,6 +33,7 @@
|
|||||||
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@show
|
@show
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,39 @@
|
|||||||
@section('title', 'Neue Veranstaltung')
|
@section('title', 'Neue Veranstaltung')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<form>
|
<form method="POST" action="{{ route('veranstaltung.store') }}">
|
||||||
<div class="form-group">
|
<div class="row">
|
||||||
<label for="title">Veranstaltungsname</label>
|
<div class="form-group col-md-8">
|
||||||
<input type="text" class="form-control" id="title" aria-describedby="titleHelp" placeholder="Veranstaltungsnamen eingeben">
|
<label for="name">Veranstaltungsname</label>
|
||||||
<small id="titleHelp" class="form-text text-muted">Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird.</small>
|
<input type="text" name="name" class="form-control" id="title" aria-describedby="nameHelp" placeholder="Veranstaltungsnamen eingeben" value="{{ $model->name or "" }}" required>
|
||||||
|
<small id="nameHelp" class="form-text text-muted">Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird.</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="gaeste">Anzahl der Gäste</label>
|
||||||
|
<input type="number" name="gaeste" class="form-control" id="gaeste" aria-describedby="gaesteHelp" placeholder="Gastanzahl eingeben">
|
||||||
|
<small id="gaesteHelp" class="form-text text-muted">Die ungefähre Anzahl an Gästen zur Veranstaltung</small>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="beginn">Veranstaltungsbeginn</label>
|
||||||
|
<input type="datetime-local" name="beginn" class="form-control" id="beginn" aria-describedby="beginnHelp" placeholder="Veranstaltungsbeginn eingeben" value="{{ $model->beginn->format('Y-m-d\TH:i:s') }}" required>
|
||||||
|
<small id="beginnHelp" class="form-text text-muted">Der Zeitpunkt, an dem die Veranstaltung beginnt.</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="ende">Veranstaltungsende</label>
|
||||||
|
<input type="datetime-local" name="ende" class="form-control" id="ende" aria-describedby="endeHelp" placeholder="Veranstaltungende eingeben">
|
||||||
|
<small id="beginnHelp" class="form-text text-muted">Der Zeitpunkt, an dem die Veranstaltung wahrscheinlich endet. (optional)</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="Hinweise">Hinweise</label>
|
||||||
|
<textarea class="form-control" name="hinweise" id="hinweise" aria-describedby="hinweiseHelp" rows="3"></textarea>
|
||||||
|
<small id="hinweiseHelp" class="form-text text-muted">Hinweise zur Veranstalung</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
@endsection
|
@endsection
|
||||||
41
resources/views/veranstaltung/edit.blade.php
Normal file
41
resources/views/veranstaltung/edit.blade.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('title', 'Veranstaltung bearbeiten')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form method="POST" action="{{ route('veranstaltung.update', ['id' => $id]) }}">
|
||||||
|
{!! method_field('put') !!}
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-8">
|
||||||
|
<label for="name">Veranstaltungsname</label>
|
||||||
|
<input type="text" name="name" class="form-control" id="title" aria-describedby="nameHelp" placeholder="Veranstaltungsnamen eingeben" value="{{ $name or "" }}" required>
|
||||||
|
<small id="nameHelp" class="form-text text-muted">Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird.</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="gaeste">Anzahl der Gäste</label>
|
||||||
|
<input type="number" name="gaeste" class="form-control" id="gaeste" aria-describedby="gaesteHelp" placeholder="Gastanzahl eingeben" value="{{ $gaeste }}">
|
||||||
|
<small id="gaesteHelp" class="form-text text-muted">Die ungefähre Anzahl an Gästen zur Veranstaltung</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="beginn">Veranstaltungsbeginn</label>
|
||||||
|
<input type="datetime-local" name="beginn" class="form-control" id="beginn" aria-describedby="beginnHelp" placeholder="Veranstaltungsbeginn eingeben" value="{{ (new \Carbon\Carbon($beginn))->format('Y-m-d\TH:i') }}" required>
|
||||||
|
<small id="beginnHelp" class="form-text text-muted">Der Zeitpunkt, an dem die Veranstaltung beginnt.</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="ende">Veranstaltungsende</label>
|
||||||
|
<input type="datetime-local" name="ende" class="form-control" id="ende" aria-describedby="endeHelp" placeholder="Veranstaltungende eingeben" value="{{ (new \Carbon\Carbon($ende))->format('Y-m-d\TH:i') }}">
|
||||||
|
<small id="beginnHelp" class="form-text text-muted">Der Zeitpunkt, an dem die Veranstaltung wahrscheinlich endet. (optional)</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label for="Hinweise">Hinweise</label>
|
||||||
|
<textarea class="form-control" name="hinweise" id="hinweise" aria-describedby="hinweiseHelp" rows="3">{{ $hinweise }}</textarea>
|
||||||
|
<small id="hinweiseHelp" class="form-text text-muted">Hinweise zur Veranstalung</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||||
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
|
</form>
|
||||||
|
@endsection
|
||||||
@ -2,7 +2,32 @@
|
|||||||
@section('title', 'Veranstaltungen')
|
@section('title', 'Veranstaltungen')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center">Name</th>
|
||||||
|
<th class="text-center">Datum</th>
|
||||||
|
<th class="text-center">Zeit</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
@foreach ($veranstaltungen as $v)
|
@foreach ($veranstaltungen as $v)
|
||||||
<li>{{ $v->name }} | {{ $v->beginn }} </li>
|
<tr>
|
||||||
|
<td>{{ $v->name }}</td>
|
||||||
|
<td>{{ $v->beginn->format('d.m.Y') }}</td>
|
||||||
|
<td>{{ $v->beginn->format('H:i') }}</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-link m-0" href="{{ route('veranstaltung.show', [$v]) }}">Details</a>
|
||||||
|
<a class="btn btn-link m-0" href="{{ route('veranstaltung.edit', [$v]) }}">Bearbeiten</a>
|
||||||
|
<a class="btn btn-link m-0" href="{{ route('veranstaltung.enter', [$v]) }}">Eintragen</a>
|
||||||
|
<form method="POST" action="{{ route('veranstaltung.destroy', $v) }}">
|
||||||
|
{!! method_field('delete') !!}
|
||||||
|
{!! csrf_field() !!}
|
||||||
|
<button class="btn btn-link text-danger">Löschen</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
</table>
|
||||||
@endsection
|
@endsection
|
||||||
36
resources/views/veranstaltung/show.blade.php
Normal file
36
resources/views/veranstaltung/show.blade.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('title', 'Neue Veranstaltung')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<h2 class="display-2">{{ $name }}</h2>
|
||||||
|
<hr/>
|
||||||
|
<dl class="row">
|
||||||
|
<dt class="col-md-2">
|
||||||
|
Datum
|
||||||
|
</dt>
|
||||||
|
<dd class="col-md-10">
|
||||||
|
{{ (new Carbon\Carbon($beginn))->formatLocalized("%A, %d. %B %Y")}}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-md-2">
|
||||||
|
Uhrzeit
|
||||||
|
</dt>
|
||||||
|
<dd class="col-md-10">
|
||||||
|
{{ (new Carbon\Carbon($beginn))->format("H:i") }} -
|
||||||
|
{{ $ende ? (new Carbon\Carbon($ende))->format("H:i") : "Open End" }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-md-2">
|
||||||
|
Gäste
|
||||||
|
</dt>
|
||||||
|
<dd class="col-md-10">
|
||||||
|
{{ $gaeste }}
|
||||||
|
</dd>
|
||||||
|
<dt class="col-md-2">
|
||||||
|
Hinweise
|
||||||
|
</dt>
|
||||||
|
<dd class="col-md-10">
|
||||||
|
{{ $hinweise }}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<hr/>
|
||||||
|
<a href="{{ route('veranstaltung.edit', ['id' => $id]) }}">Bearbeiten</a>
|
||||||
|
@endsection
|
||||||
@ -15,4 +15,6 @@ Route::get('/', function () {
|
|||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('veranstaltung/{veranstaltung}/enter', 'VeranstaltungController@enter')
|
||||||
|
->name('veranstaltung.enter');
|
||||||
Route::resource('veranstaltung','VeranstaltungController');
|
Route::resource('veranstaltung','VeranstaltungController');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user