public function addAction() { $user = new Model\User(); $form = new UserForm\Add($user); if ($this->request->isPost()) { $form->bind($this->request->getPost(), $user); if ($form->isValid()) { $pw = $user->password; $user->password = password_hash($pw, PASSWORD_BCRYPT); $user->save(); $char = new Model\Character(); $char->user_id = $user->id; $char->name = $user->character; $char->game_id = $user->game_id; $char->save(); $role = new Model\Role(); $role->user_id = $user->id; $role->role = 'user'; $role->save(); $this->session->set('auth', $user); $this->flashSession->success('User Saved'); $this->response->redirect('user'); } } $this->view->form = $form; $this->view->site = 'user'; $this->view->title = 'User Add'; }
public function fitsAction() { $user = $this->session->get('auth'); $id = $this->dispatcher->getParam('id'); $char = Model\Character::findFirst(array('id = :cid:', 'bind' => array('cid' => $id))); //pull all the relevant data for sorting the results out of the url $meta = new PaginationMeta($this->dispatcher, array('fid' => 'id', 'type' => 'type_id', 'name' => 'name', 'date' => 'date_created'), array('order_by' => 'id', 'order' => 0, 'limit' => 10)); $meta->baseLink = "character/fits/{$id}"; //make the paginator $paginator = new Paginator\Adapter\Model(array('data' => Model\Fit::find(array("character_id = :cid:", "order" => $meta->query, "bind" => array('cid' => $char->id))), 'limit' => $meta->limit, 'page' => $meta->page)); //set the data $this->view->user = $user; $this->view->char = $char; $this->view->page = $paginator->getPaginate(); $this->view->page->meta = $meta; $this->view->site = 'user'; $this->view->title = $char->name . "'s Fits"; }