Commit c8b7cc3d authored by Vytor Calixto's avatar Vytor Calixto 👾

Eventos salvando

parent 810b655d
......@@ -31,6 +31,18 @@ class EventController extends Controller
]);
}
public function saveEvent(Request $request) {
$event = Event::create([
'name' => $request->name,
'type' => $request->type,
'date' => $request->date,
'place' => $request->place,
'hours' => $request->hours,
]);
$event->save();
return redirect('/eventos');
}
public function eventIndex() {
$events = Event::all();
return view('events.index', [
......
......@@ -17,6 +17,7 @@ Route::get('/', 'HomeController@index');
Route::get('/eventos', 'EventController@index'); //lista todos os eventos
// Route::get('/eventos/{evento}', 'EventController@eventIndex'); //mostra um evento específico
Route::get('/eventos/novo', 'EventController@newEvent'); //Formulário para novo evento
Route::post('/eventos/novo', 'EventController@saveEvent'); //Formulário para novo evento
Route::auth();
......
<form class="" action="" method="post">
<div class="input-group">
<span class="input-group-addon">Nome</span>
<input type="text" name="name" class="form-control"class="form-control" value="{{ $event->name }}">
</div>
<div class="input-group">
<span class="input-group-addon">Tipo</span>
<input type="text" name="type" class="form-control" value="{{ $event->type }}">
</div>
<div class="input-group">
<span class="input-group-addon">Data</span>
<input type="date" name="date" class="form-control" value="{{ $event->date }}">
</div>
<div class="input-group">
<span class="input-group-addon">Local</span>
<input type="text" name="place" class="form-control"class="form-control" value="{{ $event->place }}">
</div>
<div class="input-group">
<span class="input-group-addon">Horas formativas</span>
<input type="number" name="hours" class="form-control"class="form-control" value="{{ $event->hours }}">
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<fieldset>
<div class="input-group">
<span class="input-group-addon">Nome</span>
<input type="text" name="name" class="form-control"class="form-control" value="{{ $event->name }}">
</div>
<div class="input-group">
<span class="input-group-addon">Tipo</span>
<input type="text" name="type" class="form-control" value="{{ $event->type }}">
</div>
<div class="input-group">
<span class="input-group-addon">Data</span>
<input type="date" name="date" class="form-control" value="{{ $event->date }}">
</div>
<div class="input-group">
<span class="input-group-addon">Local</span>
<input type="text" name="place" class="form-control" value="{{ $event->place }}">
</div>
<div class="input-group">
<span class="input-group-addon">Horas formativas</span>
<input type="number" name="hours" class="form-control" value="{{ $event->hours }}">
</div>
<div class="input-group">
<span class="input-group-addon">Texto do certificado</span>
<input type="textarea" name="certificate_text" class="form-control" value="{{ $event->certificate_text }}">
</div>
</fieldset>
<button type="submit" name="button" class="btn btn-primary">Enviar</button>
<a role="button" href="{{ url('/eventos') }}" class="btn btn-default">Cancelar</a>
</form>
......@@ -16,7 +16,7 @@
@if (count($events) > 0)
@foreach ($events as $evt)
<li class="list-group-item">
{{ $evt->name }}
{{ $evt->name }} - {{$evt->date}} em {{$evt->place}}
</li>
@endforeach
@else
......
......@@ -11,7 +11,7 @@
@if (count($futureEvents) > 0)
@foreach ($futureEvents as $evt)
<li class="list-group-item">
{{ $evt->name }}
{{ $evt->name }} - {{$evt->date}} em {{$evt->place}}
</li>
@endforeach
@else
......@@ -30,7 +30,7 @@
@if (count($pastEvents) > 0)
@foreach ($pastEvents as $evt)
<li class="list-group-item">
{{ $evt->name }}
{{ $evt->name }} - {{$evt->date}} em {{$evt->place}}
</li>
@endforeach
@else
......
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