TodoController::create PHP Method

create() public method

public create ( )
    public function create()
    {
        $content = $this->request->data("content");
        $todo = $this->todo->create(Session::getUserId(), $content);
        if (!$todo) {
            // in case of normal post request
            Session::set('errors', $this->todo->errors());
            return $this->redirector->root("Todo");
            // in case of ajax
            // $this->view->renderErrors($this->todo->errors());
        } else {
            // in case of normal post request
            Session::set('success', "Todo has been created");
            return $this->redirector->root("Todo");
            // in case of ajax
            // $this->view->renderJson(array("success" => "Todo has been created"));
        }
    }