Commit 874911ed authored by dm141569's avatar dm141569 Committed by BZ

Add Post Method for new Meetup

parent 393ef83e
<?php namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;
use App\Event;
......@@ -33,7 +34,8 @@ class HomeController extends Controller {
{
// $events = DB::table('events')->get();
$events = Event::orderBy('time', 'asc')
$events = Event::orderBy('date', 'asc')
->orderBy('time', 'asc')
->get()
->groupBy('date');
......@@ -73,24 +75,24 @@ class HomeController extends Controller {
*
* @Post("/")
*/
public function create()
public function create(Request $request)
{
/* $success = DB::table('events')->insert([
'name' => 'Bernhard',
'contact' => 'mt111073@fhstp.ac.at',
'sport' => 'Laufen',
'date' => '2014-10-22',
'time' => '20:00:00',
'meeting_place' => 'FH Aula',
'updated_at' => '1413543572',
'created_at' => '1413543572'
$success = DB::table('events')->insert([
'name' => $request->get('name'),
'contact' => $request->get('contact'),
'sport' => $request->get('sport'),
'date' => $request->get('date'),
'time' => $request->get('time'),
'meeting_place' => $request->get('meetupPlace'),
'updated_at' => time(),
'created_at' => time()
]);
if ($success) {
return true;
return 'true';
} else {
return false;
} */
return 'false';
}
}
/**
......
......@@ -10,20 +10,73 @@ SPORTMEETUPFH.Main = (function() {
var data = null;
var currentEvent = null;
/**
* Load data via AJAX call
* and append to the view
*/
function loadData() {
// Loading...
$.get('/', function(d) {
data = d;
$.each(data, function(key, value) {
var section = $(document.createElement('section'));
var header = $(document.createElement('header'));
var h1 = $(document.createElement('h1'))
h1.append(key);
header.append(h1);
section.append(header);
$('#meetups').append(section);
$.each(value, function(k, v) {
var div = $(document.createElement('div'));
$(div).data('meetup-array-id', k);
$(div).data('meetup-date', v.date);
$(div).append(v.name);
$(div).append(v.sport);
$(div).append(v.time);
$(div).bind('click', details);
$(section)
.append(div)
.hide()
.slideDown();
});
});
// Loading done.
});
}
/**
* Create a new meetup
*/
function createMeetup() {
// Validierung findet mit HTML5 statt, müsste eigentlich auch noch spearat mit JS und am Backend stattfinden, aus Zeitgründen wird das weggelassen.
$.post('/1', {
name: $('#name').val(),
contact: $('#contact').val(),
sport: $('#sport').val(),
date: $('#date').val(),
time: $('#time').val()
$.post('/', {
_token: $('#_token').val(),
name: $('#name').val(),
contact: $('#contact').val(),
sport: $('#sport').val(),
date: $('#date').val(),
time: $('#time').val(),
meetupPlace: $('#meetup-place').val()
});
$('#create')
.find("input[type=text], textarea")
.val('');
$('#meetups').empty(); // Quick and Dirty Solution
loadData();
return false;
}
......@@ -76,42 +129,7 @@ SPORTMEETUPFH.Main = (function() {
* Load data and call event listener setup
*/
init: function() {
// Loading...
$.get('/', function(d) {
data = d;
$.each(data, function(key, value) {
var section = $(document.createElement('section'));
var header = $(document.createElement('header'));
var h1 = $(document.createElement('h1'))
h1.append(key);
header.append(h1);
section.append(header);
$('#meetups').append(section);
$.each(value, function(k, v) {
var div = $(document.createElement('div'));
$(div).data('meetup-array-id', k);
$(div).data('meetup-date', v.date);
$(div).append(v.name);
$(div).append(v.sport);
$(div).append(v.time);
$(div).bind('click', details);
$(section)
.append(div)
.hide()
.slideDown();
});
});
// Loading done.
});
loadData();
this.initListeners();
},
......
......@@ -14,40 +14,43 @@
</header>
<main role="main">
<article id="meetups">
<section id="create-meetup">
<form id="create" method="post" action="/">
<fieldset>
<legend>Sportmeetup erstellen</legend>
<section id="create-meetup">
<form id="create" method="post" action="/">
<fieldset>
<legend>Sportmeetup erstellen</legend>
<label for="name">Dein Name:</label>
<input type="text" name="name" id="name" placeholder="Name eingeben" required="required" />
<input type="hidden" name="_token" id="_token" value="<?php echo csrf_token(); ?>" />
<label for="contact">Kontaktdaten:</label>
<input type="text" name="contact" id="contact" placeholder="E-Mail, Telefon,..." required="required"/>
<label for="name">Dein Name:</label>
<input type="text" name="name" id="name" placeholder="Name eingeben" required="required" />
<label for="sport">Sportart:</label>
<input type="text" name="sport" id="sport" placeholder="Sportart eintragen" required="required"/>
<label for="contact">Kontaktdaten:</label>
<input type="text" name="contact" id="contact" placeholder="E-Mail, Telefon,..." required="required"/>
<label for="date">Datum:</label>
<input type="date" name="date" id="date" placeholder="An welchem Tag soll das stattfinden?" required="required"/>
<label for="sport">Sportart:</label>
<input type="text" name="sport" id="sport" placeholder="Sportart eintragen" required="required"/>
<label for="time">Zeit:</label>
<input type="time" name="time" id="time" placeholder="zu welcher Uhrzeit?" required="required"/>
<label for="date">Datum:</label>
<input type="date" name="date" id="date" placeholder="An welchem Tag soll das stattfinden?" required="required"/>
<label for="meetup-place">Treffpunkt:</label>
<input type="text" name="meetup-place" id="meetup-place" placeholder="Wo trefft ihr euch?" required="required"/>
<label for="time">Zeit:</label>
<input type="time" name="time" id="time" placeholder="zu welcher Uhrzeit?" required="required"/>
<label for="notes">Notizen:</label>
<input type="text" name="notes" id="notes" placeholder="Sonstige Bemerkungen" />
<label for="meetup-place">Treffpunkt:</label>
<input type="text" name="meetup-place" id="meetup-place" placeholder="Wo trefft ihr euch?" required="required"/>
<input type="submit" name="submit-create" id="submit-create" value="Erstellen"/>
</fieldset>
</form>
</section>
</article>
<label for="notes">Notizen:</label>
<input type="text" name="notes" id="notes" placeholder="Sonstige Bemerkungen" />
<aside id="details">
<input type="submit" name="submit-create" id="submit-create" value="Erstellen"/>
</fieldset>
</form>
</section>
<section id="meetups">
</section>
<section id="details">
<header>
<h1></h1>
</header>
......@@ -68,7 +71,7 @@
<footer>
<a href="/" title="Back" id="btn-back">&lt; Zurück</a>
</footer>
</aside>
</section>
</main>
<footer>
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment