/** * @param Talk $talk * @param bool $sendReminder */ private function pushTalk(Talk $talk, $sendReminder) { $timezone = new \DateTimeZone(config('app.timezone')); // Generic Layout $title = $talk->title; $layout = new Pin\Layout\Calendar($title); $layout->setBody($talk->speaker ? $talk->speaker->name : 'n/a'); if ($talk->track) { $location = $talk->track == 9 ? 'Unconf' : 'Track ' . $talk->track; $layout->setLocationName($location); } // Put it all together $pin = new Pin('talk-' . $talk->id, new \DateTime($talk->starts_at->subHour()->format('Y-m-d H:i:s'), $timezone), $layout); //new \DateTime('2015-10-02 22:45:00', $timezone), $layout); // add duration if ($talk->starts_at && $talk->ends_at) { $duration = $talk->ends_at->diffInMinutes($talk->starts_at); $pin->setDuration($duration); } // Reminders if ($sendReminder) { $reminders = [new Pin\Reminder\Generic(new \DateTime($talk->starts_at->subHour()->subMinutes(5)->format('Y-m-d H:i:s'), $timezone), 'Upcoming ' . ($talk->is_talk ? 'talks' : $talk->title), Pin\Icon::TIMELINE_CALENDAR)]; $pin->setReminders($reminders); } $pusher = new Pusher(); if (config('app.debug')) { $pusher->deleteShared(config('pebble.api_key'), $pin); } $pusher->pushShared(config('pebble.api_key'), ['all'], $pin); \Log::debug('Pushed pebble talk: ' . $title . ', reminder: ' . ($sendReminder ? 'yes' : 'no')); }