/** * Store a newly created resource in storage. * * @return Response */ public function postGeolog() { $key = \Input::get('key'); //$user = \Apiauth::user($key); $user = \Device::where('key', '=', $key)->first(); if (!$user) { $actor = 'no id : no name'; \Event::fire('log.api', array($this->controller_name, 'post', $actor, 'device not found, upload image failed')); return \Response::json(array('status' => 'ERR:NODEVICE', 'timestamp' => time(), 'message' => 'Device Unregistered')); } $json = \Input::all(); $batch = \Input::get('batch'); $result = array(); foreach ($json as $j) { if (isset($j['logId'])) { if (isset($j['datetimestamp'])) { $j['mtimestamp'] = new \MongoDate(strtotime($j['datetimestamp'])); } $log = \Geolog::where('logId', $j['logId'])->first(); if ($log) { $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['logId']); } else { \Geolog::insert($j); $result[] = array('status' => 'OK', 'timestamp' => time(), 'message' => $j['logId']); } } } //print_r($result); //die(); $actor = $user->identifier . ' : ' . $user->devname; \Event::fire('log.api', array($this->controller_name, 'get', $actor, 'sync scan log')); return Response::json($result); }