Ejemplo n.º 1
0
 public function postAdd()
 {
     list($deviceToken, $deviceName) = ColdValidator::instance()->inputs(array('device_token', 'device_name'));
     $device = Device::where('device_token', $deviceToken)->first();
     if (empty($device)) {
         return Device::newDevice($this->currentSession->user_id, $deviceName, $deviceToken);
     }
     if ($device->user_id != $this->currentSession->user_id) {
         throw new \Exception('This device is being tracked by another ID', 302);
     } else {
         throw new \Exception('This device is being tracked by you', 303);
     }
 }