public function edit($id) { if ($this->shouldLockIfNoPermission('data.edit')) { return; } $customerService = new Customer($this->db); if ($this->request->is('post')) { if ($customerService->updateCustomer($id, $_POST)) { $this->flash->success('Updated customer successfully!'); } else { $this->flash->addMany($customerService->getAllMessages(), 'warning'); } return $this->redirect('/customers/view/' . $id); } $item = $customerService->findById($id); if ($item === null) { $this->flash->error('Unable to find customer!'); return $this->redirect('/customers'); } $item['created'] = $this->formatNullableDate($item['created']); $this->set('item', $item); $deviceService = new Device($this->db); $devices = $deviceService->findAllByCustomerId($id); if ($devices === null) { $this->flash->error('Unable to get computer list!'); return $this->redirect('/customers'); } $this->set('devices', $devices); }