$res = ""; foreach ($contents as $row) { foreach ($row as $key => $val) { if (is_array($val)) { 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
/** * Function that deletes a specified event from worker's calendar. * * @return Response */ public function deleteEvent() { // Validate Input. $validator = Validator::make(Input::all(), array('id' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } // Get the event and delete it. $event = Calendar::find(Input::get('id')); $event->delete(); // Return response. $response['state'] = 'Success'; $response['message'] = 'Evento eliminado exitosamente!'; return response()->json($response); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $calendar = Calendar::find($id); $calendar->delete(); // redirect Session::flash('message', 'Successfully deleted!'); return redirect('home'); }