Example #1
0
 /**
  * @param $name
  * @param TodoList $todoList
  * @param Carbon $deadline
  * @return Todo
  */
 public function create($name, TodoList $todoList, Carbon $deadline = null)
 {
     $todo = new Todo();
     $todo->name = $name;
     if ($deadline) {
         $todo->deadline = $deadline;
     }
     $todoList->todo()->save($todo);
     return $todo;
 }
 /**
  * @param $id
  * @param bool $all
  * @param bool $finished
  * @return mixed
  */
 public function todoCollection($id, $all = true, $finished = false)
 {
     if ($all) {
         return TodoList::find($id)->todo()->orderBy('created_at', 'desc')->get();
     }
     return TodoList::find($id)->todo->where('finished', (int) $finished)->orderBy('created_at', 'desc');
 }