本文整理汇总了PHP中Device::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::find方法的具体用法?PHP Device::find怎么用?PHP Device::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
/**
* Display a listing of the resource.
*
* @return Response
*/
public function logout()
{
$input = Input::all();
$device = Device::where('device_id', $input['device_id'])->where('user_id', $input['user_id'])->first();
if ($device) {
if ($device->session_id == $input['session_id']) {
Device::find($device->id)->update(['session_id' => null]);
return Common::returnData(200, SUCCESS, $input['user_id'], '');
} else {
throw new Prototype\Exceptions\UserSessionErrorException();
}
}
throw new Prototype\Exceptions\DeviceErrorException();
}
示例2: getSessionId
public static function getSessionId($input, $userId)
{
$device = Device::where('device_id', $input['device_id'])->where('user_id', $userId)->first();
if ($device) {
if (empty($input['session_id'])) {
$sessionId = $device->session_id;
if (!$sessionId) {
$sessionId = generateRandomString();
Device::find($device->id)->update(['session_id' => $sessionId]);
}
} else {
if ($device->session_id == $input['session_id']) {
$sessionId = $input['session_id'];
} else {
throw new Prototype\Exceptions\UserSessionErrorException();
}
}
} else {
$sessionId = generateRandomString();
Device::create(['device_id' => $input['device_id'], 'user_id' => $userId, 'session_id' => $sessionId]);
}
return $sessionId;
}
示例3: parseDevices
function parseDevices($domainNode, $domainName)
{
$i = 0;
$deviceNodes = $this->xpath->query(".//x:node", $domainNode);
if ($deviceNodes) {
foreach ($deviceNodes as $deviceNode) {
$idString = $deviceNode->getAttribute('id');
$id = explode("=", $idString);
$deviceName = $id[count($id) - 1];
$geo = Device::find()->where(['domain' => $domainName, 'node' => $deviceName])->asArray()->one();
if (!$geo) {
$geo = $this->parseLocation($domainName, $deviceName);
Device::createIfNew($domainName, $deviceName, $geo['lat'], $geo['lng'], $geo['address']);
$i++;
}
$location = $this->xml->createElement('CtrlPlane:location');
$lat = $this->xml->createElement('CtrlPlane:latitude', $geo['lat']);
$lng = $this->xml->createElement('CtrlPlane:longitude', $geo['lng']);
$address = $this->xml->createElement('CtrlPlane:address', $geo['address']);
$location->appendChild($lat);
$location->appendChild($lng);
$location->appendChild($address);
$deviceNode->appendChild($location);
}
if ($i > 3) {
$i = 0;
sleep(1);
}
}
}
示例4: edit
public function edit($id)
{
$device = Device::find($id);
return View::make('devices.edit', array('device' => $device, 'status' => $this->status, 'types' => $this->types, 'users' => $this->users, 'region' => $this->region));
}