74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Seattemplate;
|
|
use Request;
|
|
use App\Seat;
|
|
|
|
use Log;
|
|
|
|
class SeatingController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$seatmaps=Seattemplate::all();
|
|
return view('admin.seating.index',compact('seatmaps'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('admin.seating.create');
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
$seattemplate=Request::all();
|
|
|
|
$seattemplate["map"] = preg_replace("/[\r]/",'',$seattemplate["map"]).'';
|
|
$newSeattemplate = Seattemplate::create($seattemplate);
|
|
|
|
//don't interpret \n ... :/
|
|
$correctMap = '';
|
|
$strlen = strlen( $newSeattemplate->map );
|
|
for( $i = 0; $i <= $strlen; $i++ ) {
|
|
$char = substr( $newSeattemplate->map, $i, 1 );
|
|
if($char == "\n"){
|
|
$correctMap=$correctMap.'\n';
|
|
}else{
|
|
$correctMap= $correctMap.''.$char;
|
|
}
|
|
|
|
}
|
|
$newSeattemplate->map = $correctMap;
|
|
|
|
$newSeattemplate->save();
|
|
|
|
\Session::flash('flash_message', 'Der Sitzplan '.$seattemplate["name"].' wurde erfolgreich erstellt');
|
|
return redirect('admin/seating');
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function edit($id)
|
|
{
|
|
$seattemplate=Seattemplate::find($id);
|
|
|
|
return view('admin.seating.edit',compact('seattemplate'));
|
|
}
|
|
|
|
|
|
public function destroy($id)
|
|
{
|
|
$seatmap = Seattemplate::find($id);
|
|
$name = $seatmap->name;
|
|
$seatmap->delete();
|
|
\Session::flash('flash_message', 'Der Sitzplan '.$name." wurde erfolgreich gelöscht!");
|
|
return redirect('admin/seating');
|
|
}
|
|
}
|