__construct Auth::checkAuthentication(); } /** * This method controls what happens when you move to /note/index in your app. * Gets all notes (of the user). */ public function index() { $this->View->render('note/index', array( 'notes' => NoteModel::getAllNotes() )); } /** * This method controls what happens when you move to /dashboard/create in your app. * Creates a new note. This is usually the target of form submit actions. * POST request. */ public function create() { NoteModel::createNote(Request::post('note_text')); Redirect::to('note'); } /** * This method controls what happens when you move to /note/edit(/XX) in your app. * Shows the current content of the note and an editing form. * @param $note_id int id of the note */ public function edit($note_id) { $this->View->render('note/edit', array( 'note' => NoteModel::getNote($note_id) )); } /** * This method controls what happens when you move to /note/editSave in your app. * Edits a note (performs the editing after form submit). * POST request. */ public function editSave() { NoteModel::updateNote(Request::post('note_id'), Request::post('note_text')); Redirect::to('note'); } /** * This method controls what happens when you move to /note/delete(/XX) in your app. * Deletes a note. In a real application a deletion via GET/URL is not recommended, but for demo purposes it's * totally okay. * @param int $note_id id of the note */ public function delete($note_id) { NoteModel::deleteNote($note_id); Redirect::to('note'); } }