Add Route and Controller for ICS download

Provide a route and method for people to download an ICS file
This commit is contained in:
James Mowatt 2016-09-11 16:50:12 +01:00
parent 9579dfb10c
commit ca4795e9bc
2 changed files with 17 additions and 0 deletions

View File

@ -124,4 +124,16 @@ class EventViewController extends Controller
'message' => 'Message Successfully Sent',
]);
}
public function showCalendarIcs(Request $request, $event_id)
{
$event = Event::findOrFail($event_id);
$icsContent = $event->getIcsForEvent();
return response()->make($icsContent, 200, [
'Content-Type' => 'application/octet-stream',
'Content-Disposition' => 'attachment; filename="event.ics'
]);
}
}

View File

@ -116,6 +116,11 @@ Route::group(['prefix' => 'e'], function () {
'uses' => 'EventViewEmbeddedController@showEmbeddedEvent',
]);
Route::get('/{event_id}/calendar.ics', [
'as' => 'downloadCalendarIcs',
'uses' => 'EventViewController@showCalendarIcs',
]);
Route::get('/{event_id}/{event_slug?}', [
'as' => 'showEventPage',
'uses' => 'EventViewController@showEventHome',