public function create() { // get surah $QuranModel = new Quran(); $surahs = $QuranModel->getSurah(); $NotesModel = new Notes(); // send to view $data['surahs'] = $surahs; $data['notesDetail'] = $NotesModel->get(); $data[''] = ''; $dataHTML['modal_title'] = 'Simpan Note'; $dataHTML['modal_body'] = view('notes_form', $data)->render(); $dataHTML['modal_footer'] = ''; return response()->json($dataHTML); }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Request $request) { if (!isset($_SESSION["timer"])) { $_SESSION["timer"] = time(); } $user_id = Auth::user()->id; if (is_null($user_id)) { return redirect("/auth/login")->withErrors(["Access not allowed, you must login"]); } $notes = Notes::where('user_id', $user_id)->first()->mynotes; $tbd = Tbd::where('user_id', $user_id)->first()->mytbd; $linksArray = Websites::where('user_id', $user_id)->first()->mylink; $email = Auth::user()->email; $website = explode(',', $linksArray); $image = DB::table('myimages')->where('user_id', $user_id)->lists('myimage'); Cookie::queue(Cookie::make('loginEmail', $email, 42 * 60)); return view('home', compact('notes', 'tbd', 'website', 'image')); }
public function getReminder() { $reminders = Notes::where('reminder', '<', date('Y-m-d H:i:s', strtotime('+30 minutes')))->get(); return json_encode($reminders); }
public function destroy($id) { $note = Notes::destroy($id); echo "Deleted"; }
public function delete(Request $request) { $n = Notes::where('id', '=', $request->segment(3))->delete(); flash()->success('Record Deleted', 'Note successfully removed'); return back(); }
/** * Update the notes table */ public function updateNotes($user_id) { $getNotes = Input::get('notes'); $getTBD = Input::get('tbd'); $getLinks = Input::get('website'); $imageFile = $_FILES['image']['name']; $fileErrors = array(); if (isset($_POST['delete'])) { $getImageToDelete = Input::get('delete'); foreach ($getImageToDelete as $imgValue) { DB::table('myimages')->where('id', '=', $imgValue)->delete(); } } if ($imageFile) { //if no errors... if (!$_FILES['image']['error']) { $images = DB::table('myimages')->where('user_id', $user_id)->lists('myimage', 'id'); $valid_file = true; if (preg_match('/\\.(jpg|jpeg|gif)(?:[\\?\\#].*)?$/i', $imageFile, $matches) == 0) { $valid_file = false; $fileErrors[] = "image type not allowed, accepts only jpg or gif"; } if (sizeof($images) == 4) { $valid_file = false; $fileErrors[] = "cannot add more than 4 images"; } if (!exif_imagetype($_FILES['image']['tmp_name'])) { $valid_file = false; $fileErrors[] = "not a valid image file"; } //if the file has passed the test if ($valid_file) { $image = addslashes($_FILES['image']['tmp_name']); $name = addslashes($_FILES['image']['name']); $image = file_get_contents($image); $image = base64_encode($image); $this->saveimage($name, $image, $user_id); } } return $fileErrors; } $linksString = implode(',', array_filter($getLinks)); $websites = Websites::where('user_id', $user_id)->first(); $notes = Notes::where('user_id', '=', $user_id)->first(); $tbd = Tbd::where('user_id', '=', $user_id)->first(); $notes->mynotes = $getNotes; $tbd->mytbd = $getTBD; $websites->mylink = $linksString; $notes->save(); $tbd->save(); $websites->save(); }
public function getNotes() { $notes = new Collection(); $note_ids = DB::table('notes')->select('notes.id')->join('notes_user', 'notes_user.notes_id', '=', 'notes.id')->where('notes.author_id', $this->id)->orWhere('notes_user.user_id', $this->id)->get(); foreach ($note_ids as $id) { $notes->push(Notes::findOrFail($id->id)); } return $notes; }