function fetchArray() { $icsFile = file_get_contents($this->url); $icsData = explode("BEGIN:", $icsFile); foreach ($icsData as $key => $value) { $icsDatesMeta[$key] = explode("\n", $value); } $icsDates = array(); foreach ($icsDatesMeta as $key => $value) { $lastKey = null; foreach ($value as $subKey => $subValue) { if ($subValue != "") { if ($key != 0 && $subKey == 0) { $icsDates[$key]["BEGIN"] = $subValue; } else { $subValueArr = explode(":", $subValue, 2); if (count($subValueArr) > 1) { if (array_key_exists($subValueArr[0], $icsDates[$key])) { if (is_array($icsDates[$key][$subValueArr[0]])) { $icsDates[$key][$subValueArr[0]][] = $subValueArr[1]; } else { $temp = $icsDates[$key][$subValueArr[0]]; $icsDates[$key][$subValueArr[0]] = array($temp, $subValueArr[1]); } } else { $icsDates[$key][$subValueArr[0]] = $subValueArr[1]; } $lastKey = $subValueArr[0]; } elseif ($lastKey != null && array_key_exists($key, $icsDates)) { $icsDates[$key][$lastKey] .= "\n" . $subValue; } } } if (array_key_exists($key, $icsDates) && array_key_exists('UID', $icsDates[$key])) { $res = HiddenEvent::where('uid', '=', trim($icsDates[$key]['UID']))->where('calendar', '=', $this->id)->first(); if (!is_null($res)) { unset($icsDates[$key]); break; } } } } return $icsDates; }
foreach ($val as $val2) { $res .= $key . ":" . trim($val2) . "\r\n"; } } else { $res .= $key . ":" . trim($val) . "\r\n"; } } } return Response::make($res)->header("Content-type", "text/calendar; charset=utf-8")->header("Content-disposition", "attachment; filename=\"cal.ics\""); }); Route::get('/event/hide/{calId?}/{uid?}', function ($calId = null, $uid = null) { $calendar = Calendar::find($calId); if (is_null($calendar)) { return redirect()->back(); } $hiddenEvent = new HiddenEvent(); $hiddenEvent->calendar = $calendar->id; $hiddenEvent->uid = $uid; $hiddenEvent->save(); return redirect()->back(); }); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */