public function indexJson(Request $request, Group $group) { //dd($request); // load of actions between start and stop provided by calendar js if ($request->has('start') && $request->has('end')) { $actions = $group->actions()->where('start', '>', Carbon::parse($request->get('start')))->where('stop', '<', Carbon::parse($request->get('end')))->orderBy('start', 'asc')->get(); } else { $actions = $group->actions()->orderBy('start', 'asc')->get(); } $event = ''; $events = ''; foreach ($actions as $action) { $event['id'] = $action->id; $event['title'] = $action->name . ' (' . $group->name . ')'; $event['description'] = $action->body . ' <br/> ' . $action->location; $event['body'] = $action->body; $event['summary'] = summary($action->body); $event['location'] = $action->location; $event['start'] = $action->start->toIso8601String(); $event['end'] = $action->stop->toIso8601String(); $event['url'] = action('ActionController@show', [$group->id, $action->id]); $event['color'] = $group->color(); $events[] = $event; } return $events; }
/** * Display the specified resource. * * @param int $id * * @return Response */ public function show(Group $group) { if (Auth::check()) { $discussions = $group->discussions()->with('user', 'userReadDiscussion')->orderBy('updated_at', 'desc')->limit(5)->get(); } else { $discussions = $group->discussions()->with('user')->orderBy('updated_at', 'desc')->limit(5)->get(); } $files = $group->files()->with('user')->orderBy('updated_at', 'desc')->limit(5)->get(); $actions = $group->actions()->where('start', '>=', Carbon::now())->orderBy('start', 'asc')->limit(10)->get(); return view('groups.show')->with('group', $group)->with('discussions', $discussions)->with('actions', $actions)->with('files', $files)->with('tab', 'home'); }
/** * Renders a embedable map */ public function embed(Group $group) { $users = $group->users()->where('latitude', '<>', 0)->get(); $actions = $group->actions()->where('start', '>=', Carbon::now())->where('latitude', '<>', 0)->get(); // randomize users geolocation by a few meters foreach ($users as $user) { $user->latitude = $user->latitude + mt_rand(0, 10) / 10000; $user->longitude = $user->longitude + mt_rand(0, 10) / 10000; } return view('groups.map_embed')->with('tab', 'map')->with('group', $group)->with('users', $users)->with('actions', $actions)->with('latitude', 50.8503396)->with('longitude', 4.3517103); }
/** * Renders an ical file for a specific group */ public function group(Group $group) { // 1. Create new calendar $vCalendar = new \Eluceo\iCal\Component\Calendar(config('app.url')); $vCalendar->setName(config('mobilizator.name') . ' : ' . $group->name); $vCalendar->setDescription(summary($group->body, 500)); // returns actions started the last 60 days $actions = $group->actions()->where('start', '>=', Carbon::now()->subDays(60))->get(); foreach ($actions as $action) { // 2. Create an event $vEvent = new \Eluceo\iCal\Component\Event(); $vEvent->setDtStart($action->start); $vEvent->setDtEnd($action->stop); $vEvent->setSummary($action->name); $vEvent->setDescription(summary($action->body), 1000); $vEvent->setLocation($action->location); $vEvent->setUrl(action('ActionController@show', [$action->group->id, $action->id])); $vEvent->setUseUtc(false); //TODO fixme $vCalendar->addComponent($vEvent); } return response($vCalendar->render())->header('Content-Type', 'text/calendar; charset=utf-8')->header('Content-Disposition', 'attachment; filename="cal.ics"'); }