diff --git a/app/Http/Controllers/VeranstaltungController.php b/app/Http/Controllers/VeranstaltungController.php index 8ac7bd11..68feff6c 100644 --- a/app/Http/Controllers/VeranstaltungController.php +++ b/app/Http/Controllers/VeranstaltungController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Veranstaltung; use Illuminate\Http\Request; +use Illuminate\Http\Response; class VeranstaltungController extends Controller { @@ -24,8 +25,11 @@ class VeranstaltungController extends Controller */ public function create() { + $v = new Veranstaltung(); + $v->beginn = \Carbon\Carbon::today(); + return view ('veranstaltung.create', ['model' => - new Veranstaltung()]); + $v]); } /** @@ -36,7 +40,21 @@ class VeranstaltungController extends Controller */ 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) { - // + + return view('veranstaltung.show', $veranstaltung); } /** @@ -58,7 +77,7 @@ class VeranstaltungController extends Controller */ 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) { - // + + 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) { - // + $veranstaltung->delete(); + + return redirect()->route('veranstaltung.index'); + } + + public function enter(Request $request, Veranstaltung $veranstaltung) + { + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 70219816..8883c9c1 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,7 @@ namespace App\Providers; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; +use Carbon\Carbon; class AppServiceProvider extends ServiceProvider { @@ -15,6 +16,9 @@ class AppServiceProvider extends ServiceProvider public function boot() { Schema::defaultStringLength(191); + date_default_timezone_set("Europe/Berlin"); + setlocale(LC_TIME, "German"); + Carbon::setLocale('de'); } /** diff --git a/app/Veranstaltung.php b/app/Veranstaltung.php index 8791e0b7..6d4da0b7 100644 --- a/app/Veranstaltung.php +++ b/app/Veranstaltung.php @@ -7,5 +7,8 @@ use Illuminate\Database\Eloquent\Model; class Veranstaltung extends Model { protected $table = "veranstaltungen"; - // + + protected $fillable = ['name','beginn','ende','geaste','hinweise']; + + protected $dates = ['beginn', 'ende']; } diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index cdd07e81..52cdb87f 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -10,10 +10,11 @@ @section('navbar') @show diff --git a/resources/views/veranstaltung/create.blade.php b/resources/views/veranstaltung/create.blade.php index 82f875e3..d9013422 100644 --- a/resources/views/veranstaltung/create.blade.php +++ b/resources/views/veranstaltung/create.blade.php @@ -2,12 +2,39 @@ @section('title', 'Neue Veranstaltung') @section('content') -
-
- - - Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird. + +
+
+ + + Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird. +
+
+ + + Die ungefähre Anzahl an Gästen zur Veranstaltung +
- +
+
+ + + Der Zeitpunkt, an dem die Veranstaltung beginnt. +
+
+ + + Der Zeitpunkt, an dem die Veranstaltung wahrscheinlich endet. (optional) +
+
+
+
+ + + Hinweise zur Veranstalung +
+
+ + @endsection \ No newline at end of file diff --git a/resources/views/veranstaltung/edit.blade.php b/resources/views/veranstaltung/edit.blade.php new file mode 100644 index 00000000..bdfba76f --- /dev/null +++ b/resources/views/veranstaltung/edit.blade.php @@ -0,0 +1,41 @@ +@extends('layouts.app') +@section('title', 'Veranstaltung bearbeiten') + +@section('content') +
+ {!! method_field('put') !!} +
+
+ + + Die Bezeichnung der Veranstaltung, welcher in der Übersicht angezeigt wird. +
+
+ + + Die ungefähre Anzahl an Gästen zur Veranstaltung +
+
+
+
+ + + Der Zeitpunkt, an dem die Veranstaltung beginnt. +
+
+ + + Der Zeitpunkt, an dem die Veranstaltung wahrscheinlich endet. (optional) +
+
+
+
+ + + Hinweise zur Veranstalung +
+
+ + +
+@endsection \ No newline at end of file diff --git a/resources/views/veranstaltung/index.blade.php b/resources/views/veranstaltung/index.blade.php index c4764348..b913b45d 100644 --- a/resources/views/veranstaltung/index.blade.php +++ b/resources/views/veranstaltung/index.blade.php @@ -2,7 +2,32 @@ @section('title', 'Veranstaltungen') @section('content') + + + + + + + + + @foreach ($veranstaltungen as $v) -
  • {{ $v->name }} | {{ $v->beginn }}
  • + + + + + + @endforeach + +
    NameDatumZeit
    {{ $v->name }}{{ $v->beginn->format('d.m.Y') }}{{ $v->beginn->format('H:i') }} + Details + Bearbeiten + Eintragen +
    + {!! method_field('delete') !!} + {!! csrf_field() !!} + +
    +
    @endsection \ No newline at end of file diff --git a/resources/views/veranstaltung/show.blade.php b/resources/views/veranstaltung/show.blade.php new file mode 100644 index 00000000..38ebe824 --- /dev/null +++ b/resources/views/veranstaltung/show.blade.php @@ -0,0 +1,36 @@ +@extends('layouts.app') +@section('title', 'Neue Veranstaltung') + +@section('content') +

    {{ $name }}

    +
    +
    +
    + Datum +
    +
    + {{ (new Carbon\Carbon($beginn))->formatLocalized("%A, %d. %B %Y")}} +
    +
    + Uhrzeit +
    +
    + {{ (new Carbon\Carbon($beginn))->format("H:i") }} - + {{ $ende ? (new Carbon\Carbon($ende))->format("H:i") : "Open End" }} +
    +
    + Gäste +
    +
    + {{ $gaeste }} +
    +
    + Hinweise +
    +
    + {{ $hinweise }} +
    +
    +
    + Bearbeiten +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index aa824f7a..2c8a21c2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,4 +15,6 @@ Route::get('/', function () { return view('welcome'); }); +Route::get('veranstaltung/{veranstaltung}/enter', 'VeranstaltungController@enter') + ->name('veranstaltung.enter'); Route::resource('veranstaltung','VeranstaltungController');