/** * @return mixed */ public function getDeviceCode() { $DeviceCode = $this->settingsRepo->get('code'); if ($DeviceCode == null) { $attr = array('key' => 'code', 'value' => mt_rand(100000, 999999)); $DeviceCode = $this->settingsRepo->create($attr); } return $DeviceCode->value; }