App\Controllers\Admin\UniversalAjaxController::doAdd PHP Method

doAdd() public method

$model = ModelsFactory::getModelWithRequest($req); $this->data['items'] = $model->paginate($this->pagecount); $this->data['items']->setPath($this->router->pathFor($this->data['all_e_link'])); $this->data['fields'] = $this->getFields($model->getColumnsNames(), array('id')); $this->data['allFields'] = $model->getColumnsNames(); $this->view->render($res, 'admin\dataTables.twig', $this->data); } public function add(request $req, $res){ $this->initRoute($req); $model = ModelsFactory::getModelWithRequest($req); $this->data['fields'] = $this->getFields($model->getColumnsNames()); $builder = new BuildFields(); $builder->setFields($model->getColumnsNames())->addJsonShema($model->getAnnotations()); $this->data['ttt'] = $builder->getAll(); $this->view->render($res, 'admin\addTables.twig', $this->data); } public function edit(request $req, $res, $args){ $this->initRoute($req); $model = ModelsFactory::getModelWithRequest($req); $this->data['fields'] = $this->getFields($model->getColumnsNames(), ['id']); $this->data['fieldsValues'] = $model->find($args['id']); $this->data['type_link'] = $this->data['save_link']; $builder = new BuildFields(); $builder->setFields($model->getColumnsNames())->addJsonShema($model->getAnnotations()); $builder->build(); $builder->setType('id', 'hidden'); foreach ($this->data['fields'] as $name) { $builder->getField($name)->setValue($this->data['fieldsValues']->$name); } $this->data['ttt'] = $builder->getAll(); $this->view->render($res, 'admin\addTables.twig', $this->data); }
public doAdd ( Psr\Http\Message\ServerRequestInterface $req, $res, $args )
$req Psr\Http\Message\ServerRequestInterface
    public function doAdd(request $req, $res, $args)
    {
        $this->initRoute($req);
        $model = ModelsFactory::getModelWithRequest($req, $req->getParsedBody());
        $model->save();
        $this->flash->addMessage('success', $this->controllerName . ' success added!');
        return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('list.' . $this->controllerName));
    }