public function Add_itemAction()
 {
     $todo_id = $this->request->getPost('todo_id');
     $todo_title = $this->request->getPost('todo_title');
     $todo = Todos::find('hex(uuid) = "' . $todo_id . '"');
     if ($todo) {
         $todo_item = new Todoitems();
         $todo_item->setTodoId($todo_id);
         $todo_item->title = $todo_title;
         $todo_item->save();
     }
     return $this->response->redirect("/");
 }
예제 #2
0
 public function markAllCompleted($userId)
 {
     try {
         $todos = Todos::where('user_id', $userId)->where('status', 'incomplete')->get(array('id'))->toArray();
         if ($todos == null) {
             //No Todos found
             return 'error';
         } else {
             foreach ($todos as $todo) {
                 $tempTodo = \Todos::find($todo['id']);
                 $tempTodo->status = 'completed';
                 $tempTodo->save();
             }
             return 'success';
         }
     } catch (Exception $e) {
         \Log::error('Something Went Wrong in Todo Repository - markAllCompleted():' . $e->getMessage());
         throw new SomeThingWentWrongException();
     }
 }
 /**
  * delete
  *
  * @return Response
  */
 public function deleteIndex($todo)
 {
     $id = $todo->id;
     if (!$todo->delete()) {
         return Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
     }
     $todos = Todos::find($id);
     return empty($todos) ? Api::json(array('result' => 'success')) : Api::json(array('result' => 'error', 'error' => Lang::get('core.delete_error')));
 }
 public function indexAction()
 {
     $todos = Todos::find();
     $this->view->todos = $todos;
 }