/** * Display a listing of the resource. * * @return Response */ public function index() { // $todos = $this->todo->all(); $id = Sentry::getUser()->id; $todos = Todo::where('user_id', '=', $id)->paginate(3); return View::make('todos.index', compact('todos')); }
private static function getTodosNotActual($pagination = 10) { return Todo::where('status', '<>', '0')->orderBy('priority', 'asc')->orderBy('updated_at', 'desc')->paginate($pagination); }
/** * To search the todo list entered into the database and pass them back to the view * This method is currently used inside insertDateValue() * @param $dateValue - yy-mm-dd passed into here to find the todo list of the day in database * @return string - return all the todoList in json format */ public function printTodoList($dateValue) { $data = array(); $index = 0; //Use the dateValue (yy-mm-dd) to find all rows with the same dateValue and ignores the time //If nothing can be found, a string of empty will be returned or else the todoText in the database will be returned $todos = Todo::where('created_for', 'LIKE', $dateValue . '%')->get(); if (sizeof($todos) == 0) { $data[$index] = 'empty'; } else { foreach ($todos as $key => $todo) { $data[$index]['todo'] = $todo['todoText']; $data[$index]['done'] = $todo['done']; $data[$index]['id'] = $todo['id']; $index++; } } return json_encode($data); }
public function clean() { Todo::where('done', '=', 1)->delete(); $arr = ['type' => 'success', 'msg' => '完成事項已刪除!']; return Response::json($arr); }
/** * Add a new todo * * @param int $user_id * @param int $issue_id * @return array */ public static function add_todo($issue_id = 0) { $user_id = Auth::user()->id; // Ensure user is assigned to issue. $issue = Project\Issue::load_issue($issue_id); if (empty($issue) || $issue->assigned_to !== $user_id) { return array('success' => FALSE, 'errors' => __('tinyissue.todos_err_add')); } // Ensure issue is not already a task. $count = Todo::where('issue_id', '=', $issue_id)->where('user_id', '=', $user_id)->count(); if ($count > 0) { return array('success' => FALSE, 'errors' => __('tinyissue.todos_err_already')); } $todo = new Todo(); $todo->user_id = $user_id; $todo->issue_id = $issue_id; $todo->status = 1; $todo->save(); return array('success' => TRUE); }