/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $list = TodoList::findOrFail($id); //$items = $list->listItems()->get(); return View::make('todos.show')->withList($list); //->withItems($items); }
function processAddTodoList($todoList) { if (empty($_POST['todoListName'])) { return "fill all the values"; //return errormessage } else { $todoList = TodoList::insertToDatabase($_POST['todoListName'], $_SESSION['userId']); if (!$todoList) { return "creating todo list failed"; } else { return ""; } } }
/** * Store a newly created resource in storage. * * @return Response */ public function store($list_id) { $todo_list = TodoList::findOrFail($list_id); // define rules $rules = array('content' => array('required')); // pass input to validator $validator = Validator::make(Input::all(), $rules); // test if input fails if ($validator->fails()) { return Redirect::route('todos.items.create', $list_id)->withErrors($validator)->withInput(); } $item = new TodoItem(); $item->content = Input::get('content'); $todo_list->listItems()->save($item); return Redirect::route('todos.show', $todo_list->id)->withMessage('Item was added!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store($list_id) { $todo_list = TodoList::findOrFail($list_id); //Define rules for validation $rules = array('content' => ['required', 'unique:todo_items', 'string']); // pass rules and input to validator class $validator = Validator::make(Input::all(), $rules); // test if input fails if ($validator->fails()) { // $messages = $validator->messages(); // return $messages; return Redirect::route('todos.items.create', $list_id)->withErrors($validator)->withInput(); } $content = Input::get('content'); $item = new TodoItem(); $item->content = $content; $item->user_id = Auth::user()->id; $todo_list->listItems()->save($item); return Redirect::route('todos.show', $todo_list->id)->withMessage('Task was created! '); }
/** * @return \yii\db\ActiveQuery */ public function getTodos() { return $this->hasMany(TodoList::className(), ['id_todo' => 'todo_id'])->viaTable('usertodo', ['user_id' => 'id'])->asArray(); }
public function test_should_move_up_the_item_with_the_same_position_as_the_inserted() { $this->installAndIncludeModels(array('TodoList', 'TodoTask')); $ListA = new TodoList(array('name' => 'A')); $this->assertTrue($ListA->save()); $ListA->task->create(array('details' => 1)); $ListB = new TodoList(array('name' => 'B')); $this->assertTrue($ListB->save()); $ListB->task->create(array('details' => 2)); $TodoTask = $ListB->task->create(array('details' => 3)); $Task1 = $TodoTask->find('first', array('details' => 1)); $Task1->list->removeFromList(); $this->assertTrue($Task1->save()); $Task1->todo_list->assign($ListB); $this->assertTrue($Task1->save()); $Task1->list->insertAt(2); $ListB = $ListB->find('first', array('name' => 'B'), array('include' => 'tasks')); foreach (array_keys($ListB->tasks) as $k) { $this->assertEqual($ListB->tasks[$k]->get('position'), $k + 1); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $todo_list = TodoList::findOrFail($id)->delete(); return Redirect::route('todos.index')->withMessage('Item deleted!'); }
function show() { global $wgOut, $IP, $wgUser, $wgScriptPath; $wgOut->setPageTitle( wfMsgHtml( 'todo-list-for', $this->target->getName() ) ); $wgOut->addWikiText( "== " . wfMsg( 'todo-new-item' ) . " ==\n" ); require_once( 'TodoForm.php' ); $form = new TodoTemplate(); $form->set( 'action', $this->self->getLocalUrl( 'action=submit' ) ); $form->set( 'script', "$wgScriptPath/extensions/Todo/todo.js" ); $wgOut->addTemplate( $form ); if ( $wgUser->getName() == $this->target->getName() ) { $wgOut->addWikiText( "== " . wfMsg( 'todo-item-list' ) . " ==\n" ); $list = new TodoList( $this->target ); $list->show(); } }
/** * The form handler for AddListForm * * @param array $rawData * @param Form $form * @param SS_HTTPRequest $request */ public function doAddNewList($rawData, $form, $request) { $list = TodoList::create(); $form->saveInto($list); $list->write(); $this->redirectBack(); }
public function test_should_load_resquested_list() { $this->installAndIncludeModels(array('TodoList', 'TodoTask')); $ListA = new TodoList(array('name' => 'A')); $this->assertTrue($ListA->save()); $ListB = new TodoList(array('name' => 'B')); $this->assertTrue($ListB->save()); $Task1 = $ListB->task->create(array('details' => 1)); $Task1->todo_list->load(true); $this->assertEqual($Task1->todo_list->getId(), $ListB->getId()); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $list = $list = TodoList::findOrFail($id); if ($list->user_id == Auth::user()->id) { $list->delete(); return Redirect::route('todos.index')->withMessage("List was deleted."); } else { return Redirect::route('todos.index')->withMessage('You are not authorised to destroy this list.'); } }
<?php include_once 'config.php'; $data = $_POST['data']; $method = $_POST['method']; $user_id = (include_once 'user.php'); $data = (array) json_decode($data); $data['user_id'] = $user_id; // Connect TodoList class include 'todoClass.php'; if ($data) { $list = new TodoList($data); if ($method != '') { switch ($method) { case 'setName': $sth = $list->write('name', $list->name); break; case 'setDeadline': $sth = $list->write('deadline', $list->deadline); break; case 'create': $sth = $list->create(); break; case 'delete': $sth = $list->delete(); break; } if ($method == 'getLast') { echo $list->getLast($db); return false; }
register_error(elgg_echo('todos:action:error:title')); forward(REFERER); } if (!empty($guid)) { $entity = get_entity($guid); if (empty($entity) || !elgg_instanceof($entity, 'object', TodoList::SUBTYPE)) { register_error(elgg_echo('InvalidParameterException:NoEntityFound')); forward(REFERER); } if (!$entity->canEdit()) { register_error(elgg_echo('InvalidParameterException:NoEntityFound')); forward(REFERER); } } if (empty($entity) && can_write_to_container(0, $container_guid, 'object', TodoList::SUBTYPE)) { $entity = new TodoList(); $entity->container_guid = $container_guid; } if (empty($entity)) { // this should not happen register_error(elgg_echo('InvalidParameterException:NoEntityFound')); forward(REFERER); } $entity->title = $title; $entity->access_id = $access_id; $entity->active = true; if ($entity->save()) { system_message(elgg_echo('todos:action:todolist:edit:success')); } else { register_error(elgg_echo('todos:action:todolist:edit:error')); }