Merge pull request #199 from jmowatt/feature/ics-on-confirmation
Add user importable calendar to email
This commit is contained in:
commit
52b29fe071
|
|
@ -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'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -331,4 +331,32 @@ class Event extends MyBaseModel
|
|||
{
|
||||
return ['created_at', 'updated_at', 'start_date', 'end_date'];
|
||||
}
|
||||
|
||||
public function getIcsForEvent()
|
||||
{
|
||||
$siteUrl = URL::to('/');
|
||||
$eventUrl = $this->getEventUrlAttribute();
|
||||
|
||||
$start_date = new Carbon($this->start_date);
|
||||
$end_date = new Carbon($this->end_date);
|
||||
$timestamp = new Carbon();
|
||||
|
||||
$icsTemplate = <<<ICSTemplate
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:{$siteUrl}
|
||||
BEGIN:VEVENT
|
||||
UID:{$eventUrl}
|
||||
DTSTAMP:{$timestamp->format('Ymd\THis\Z')}
|
||||
DTSTART:{$start_date->format('Ymd\THis\Z')}
|
||||
DTEND:{$end_date->format('Ymd\THis\Z')}
|
||||
SUMMARY:$this->title
|
||||
LOCATION:{$this->venue_name}
|
||||
DESCRIPTION:{$this->description}
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
ICSTemplate;
|
||||
|
||||
return $icsTemplate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Order Reference: <b>{{$order->order_reference}}</b><br>
|
|||
Order Name: <b>{{$order->full_name}}</b><br>
|
||||
Order Date: <b>{{$order->created_at->toDayDateTimeString()}}</b><br>
|
||||
Order Email: <b>{{$order->email}}</b><br>
|
||||
|
||||
<a href="{!! route('downloadCalendarIcs', ['event_id' => $order->event->id]) !!}">Add To Calendar</a>
|
||||
<h3>Order Items</h3>
|
||||
<div style="padding:10px; background: #F9F9F9; border: 1px solid #f1f1f1;">
|
||||
<table style="width:100%; margin:10px;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue