public function add() { if ($this->shouldLockIfNoPermission('data.edit')) { return; } if ($this->request->is('post')) { $customerService = new Customer($this->db); $user = $this->session->get('user'); $result = $customerService->createCustomer($_POST, $user['username']); if (null !== $result) { $this->flash->success('Added this customer successfully!'); return $this->redirect('/customers/view/' . $result); } else { $this->flash->addMany($customerService->getAllMessages(), 'warning'); } return $this->redirect($this->request->here); } $this->set('now', date('n/j/Y', time())); }