public function view($id) { if ($this->shouldLockIfNoPermission('data.view')) { return; } $modelPart = new Part($this->db); $part = $modelPart->findById($id); if (null === $part) { $this->flash->error('Unable to find part!'); return $this->redirect('/customers'); } $modelDevice = new Device($this->db); $device = $modelDevice->findById($part['device_id']); if (null === $device) { $this->flash->error('Unable to get device!'); return $this->redirect('/customers'); } $this->set('item', $part); $this->set('device', $device); }