Commit 40d2cd18 authored by Vytor Calixto's avatar Vytor Calixto 👾

Rota para novo evento e todos os eventos

parent a10b7874
......@@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Model;
class Event extends Model
{
//
protected $fillable = ['name', 'type', 'date', 'place', 'hours', 'certificate_text'];
public function users() {
......
......@@ -6,7 +6,35 @@ use Illuminate\Http\Request;
use App\Http\Requests;
use App\Event;
class EventController extends Controller
{
//
public function __construct()
{
$this->middleware('auth');
}
public function index() {
$events = Event::all();
return view('events.index', [
'events' => $events
]);
}
public function newEvent() {
$event = new Event();
$event->date = date();
$event->certificate_text = "Certificamos que {{PARTICIPANTE}} participou {{TIPO}} {{NOME}} realizado no dia {{DATA}} com carga horária de {{HORAS}}.";
return view('home', [
'event' => $event
]);
}
public function eventIndex() {
$events = Event::all();
return view('events.index', [
'events' => $events
]);
}
}
......@@ -25,11 +25,11 @@ class HomeController extends Controller
*/
public function index()
{
$eventosFuturos = Event::where('date', '>=', date('Y-m-d').' 00:00:00')->get();
$eventosPassados = Event::where('date', '<', date('Y-m-d').' 00:00:00')->get();
$futureEvents = Event::where('date', '>=', date('Y-m-d').' 00:00:00')->get();
$pastEvents = Event::where('date', '<', date('Y-m-d').' 00:00:00')->get();
return view('welcome', [
'eventosFuturos' => $eventosFuturos,
'eventosPassados' => $eventosPassados
'futureEvents' => $futureEvents,
'pastEvents' => $pastEvents
]);
}
}
......@@ -16,6 +16,7 @@ Route::get('/', 'HomeController@index');
/* ----------- Rotas de Eventos ----------- */
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::auth();
......
<form class="" action="" method="post">
<div class="input-group">
<span class="input-group-addon">Nome</span>
<input type="text" name="name" value="{{ $event->name }}">
</div>
<div class="input-group">
<span class="input-group-addon">Tipo</span>
<input type="text" name="type" value="{{ $event->type }}">
</div>
<div class="input-group">
<span class="input-group-addon">Data</span>
<input type="date" name="date" value="{{ $event->date }}">
</div>
<div class="input-group">
<span class="input-group-addon">Local</span>
<input type="text" name="place" value="{{ $event->place }}">
</div>
<div class="input-group">
<span class="input-group-addon">Horas formativas</span>
<input type="number" name="hours" value="{{ $event->hours }}">
</div>
</form>
@extends ('layouts.app')
@section ('content')
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>Eventos</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="{{ url('/eventos/novo') }}" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-plus"></span> Novo evento</a>
<ul class="list-group">
@if (count($events) > 0)
@foreach ($events as $evt)
<li class="list-group-item">
{{ $evt->name }}
</li>
@endforeach
@else
<li class="list-group-item">
Não eventos cadastrados
</li>
@endif
</ul>
</div>
</div>
</div>
@endsection
@extends ('layouts.app')
@section ('content')
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>Novo evento</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
@include ('_form')
</div>
</div>
</div>
@endsection
......@@ -49,7 +49,7 @@
<!-- Left Side Of Navbar -->
@unless (Auth::guest())
<ul class="nav navbar-nav">
<li><a href="{{ url('/home') }}">Gerenciar Eventos</a></li>
<li><a href="{{ url('/eventos') }}">Gerenciar Eventos</a></li>
</ul>
@endunless
......
......@@ -8,8 +8,8 @@
<div class="panel-heading">Próximos eventos</div>
<div class="panel-body">
<ul class="list-group">
@if (count($eventosFuturos) > 0)
@foreach ($eventosFuturos as $evt)
@if (count($futureEvents) > 0)
@foreach ($futureEvents as $evt)
<li class="list-group-item">
{{ $evt->name }}
</li>
......@@ -27,8 +27,8 @@
<div class="panel-heading">Eventos anteriores</div>
<div class="panel-body">
<ul class="list-group">
@if (count($eventosPassados) > 0)
@foreach ($eventosPassados as $evt)
@if (count($pastEvents) > 0)
@foreach ($pastEvents as $evt)
<li class="list-group-item">
{{ $evt->name }}
</li>
......
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