/** * Display the homepage. */ public function show() { $events = Event::where('secret', false)->where('start', '>=', date('U'))->orderBy('start')->limit(5)->get(); $companies = Company::where('in_logo_bar', true)->get(); if (Auth::check()) { $message = WelcomeMessage::where('user_id', Auth::user()->id)->first(); return view('website.home.members', ['events' => $events, 'companies' => $companies, 'message' => $message]); } else { return view('website.home.external', ['events' => $events, 'companies' => $companies]); } }
public function icalCalendar(Request $request) { $calendar = new IcalCalendar('-//HYTTIOAOAc//S.A. Proto Calendar//EN'); $calendar->setName('S.A. Proto Calendar'); $calendar->setDescription('All of Proto\'s events and happenings, straight from the website!'); $calendar->setCalendarColor('#C1FF00'); $calendar->setCalendarScale('GREGORIAN'); $calendar->setMethod('PUBLISH'); foreach (Event::where('secret', false)->where('start', '>', strtotime('-6 months'))->get() as $event) { $infotext = ''; if ($event->over()) { $infotext = 'This activity is over.'; } elseif ($event->activity !== null && $event->activity->participants == -1) { $infotext = 'Sign-up required, but no participant limit.'; } elseif ($event->activity !== null && $event->activity->participants > 0) { $infotext = 'Sign-up required! There are roughly ' . $event->activity->freeSpots() . ' of ' . $event->activity->participants . ' places left.'; } else { $infotext = 'No sign-up necessary.'; } $component = (new IcalEvent())->setDtStart(new DateTime(date('d-m-Y H:i:s', $event->start)))->setDtEnd(new DateTime(date('d-m-Y H:i:s', $event->end)))->setSummary($event->title)->setDescription($infotext . ' More information: ' . route("event::show", ['id' => $event->id]))->setUseTimezone(true)->setLocation($event->location); if ($event->committee !== null) { $component->setOrganizer(new IcalOrganizer($event->committee->name)); } $calendar->addComponent($component); } return Response::make($calendar->render())->header('Content-Type', 'text/calendar; charset=utf-8')->header('Content-Disposition', 'attachment; filename="protocalendar.ics"'); }
/** * @return Event A collection of events for the weekly newsletter. */ public static function getEventsForNewsletter() { return Event::where('secret', false)->where('start', '>', date('U'))->where('start', '<', strtotime('+4 weeks'))->orderBy('start')->get(); }