/** * @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'); }