EventController:
Route:
Route::group(['middleware' => 'auth'], function() {
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/profile', 'Auth\UserController@profile')->name('profile');
Route::post('/profile', 'Auth\UserController@updateProfile')->name('updateProfile');
Route::get('event/index/{filter}', 'EventController@index')->name('indexEvent');
Route::get('event/create', 'EventController@create')->name('createEvent');
Route::post('event/store', 'EventController@store')->name('storeEvent');
Route::get('event/show/{id}', 'EventController@show')->name('showEvent');
Route::get('event/edit/{id}', 'EventController@edit')->name('editEvent');
Route::post('event/update/{id}', 'EventController@update')->name('updateEvent');
Route::get('event/destroy/{id}', 'EventController@destroy')->name('destroyEvent');
});
EventController:`
public function index()
{
$events = Event::all();
return view('event.index')->with('events', $events);
}
@extends('layouts.app')
@section('title', 'Eventos')
@section('content')
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">Eventos</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-11">
<a class="btn btn-primary" href="{{ route('createEvent') }}" role="button">Novo Evento</a>
</div><!-- /.col-lg-6 -->
<div class="col-lg-1">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Filtrar <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="{{ route('indexEvent', ['filter' => 'all']) }}">Todos os eventos</a></li>
<li><a href="{{ route('indexEvent', ['filter' => 'today']) }}">Eventos de hoje</a></li>
<li><a href="{{ route('indexEvent', ['filter' => 'five']) }}">Eventos nos próximos 5 dias</a></li>
</ul>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<table class="table table-bordered">
<tr>
<th>Título</th>
<th>Detalhes</th>
<th>Alterar</th>
<th>Excluir</th>
</tr>
@foreach($events as $event)
<tr>
<td>{{ $event->title }}</td>
<td>
<a href="{{ route('showEvent', $event->id) }}" class="fa fa-file-text-o" aria-hidden="true"></a>
</td>
<td>
<a href="{{ route('editEvent', $event->id) }}" class="fa fa-pencil" aria-hidden="true"></a>
</td>
<td>
<a href="{{ route('destroyEvent', $event->id) }}" class="fa fa-trash" aria-hidden="true"></a>
</td>
</tr>
@endforeach
</table>
</div>
</div>
@endsection