Added Methods, routes and Views for VeranstaltungController
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user