protected function getEvents() { $events = []; $start = Input::get('from') / 1000; $end = Input::get('to') / 1000; $events = Events::whereBetween('start', [date('Y-m-d', $start), date('Y-m-d', $end)])->whereBetween('end', [date('Y-m-d', $start), date('Y-m-d', $end)]); if (!in_array(Auth::user()->level, [4, 3, 2])) { $events->where('url', '<>', 'on'); } $events = $events->get(); foreach ($events as $e) { $participants = []; if (strpos($e->title, '@@')) { $participants = explode(',', substr($e->title, strpos($e->title, '@@') + 2)); } if (!empty($participants)) { $participants = User::select('id', 'fullname', 'position')->whereIn("id", $participants)->get(); } $events[] = array('id' => $e->id, 'title' => $e->title, 'url' => '#', 'participants' => $participants, 'class' => $e->class, 'start' => strtotime($e->start) . '000', 'end' => strtotime($e->end) . '000'); } echo json_encode(array('success' => 1, 'result' => $events)); }