本文整理汇总了PHP中Device::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::where方法的具体用法?PHP Device::where怎么用?PHP Device::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectCampus
public function selectCampus($id)
{
$campusid = $id;
$ipadress = $this->getIPAdress();
/*store the institutions id alongside the specific ip adress in the devices table
* and redirect user to the specific homepage
*/
$exists = Device::where('ip', '=', $ipadress);
if ($exists->count()) {
$device = $exists->first();
$device->branch_id = $campusid;
if ($device->save()) {
if (Auth::user()) {
return Redirect::route('member-home');
} else {
return Redirect::route('home');
}
}
} else {
$devicecreate = Device::create(array('ip' => $ipadress, 'branch_id' => $campusid));
if ($devicecreate) {
if (Auth::user()) {
return Redirect::route('member-home');
} else {
return Redirect::route('home');
}
}
}
return Redirect::route('selectcampus-get')->withInput()->with('global', 'Sorry!! Campus details were not loaded, please retry.');
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$key = Input::get('key');
$deliverydate = Input::get('date');
$dev = \Device::where('key', '=', $key)->first();
$model = $this->model;
$merchants = $model->where('group_id', '=', 4)->get();
//print_r($merchants);
//die();
for ($n = 0; $n < count($merchants); $n++) {
$or = new \stdClass();
foreach ($merchants[$n] as $k => $v) {
$nk = $this->underscoreToCamelCase($k);
$or->{$nk} = is_null($v) ? '' : $v;
}
$or->extId = $or->id;
unset($or->id);
//$or->boxList = $this->boxList('delivery_id',$or->deliveryId,$key);
//$or->boxObjects = $this->boxList('delivery_id',$or->deliveryId, $key , true);
$merchants[$n] = $or;
}
$actor = $key;
\Event::fire('log.api', array($this->controller_name, 'get', $actor, 'logged out'));
return $merchants;
//
}
示例3: getDevice
private function getDevice()
{
/*require_once(app_path().'/includes/ip.codehelper.io.php');
require_once(app_path().'/includes/php_fast_cache.php');
$_ip = new ip_codehelper();
$campusid = 0;
$real_client_ip_address = $_ip->getRealIP();
$visitor_location = $_ip->getLocation($real_client_ip_address);
$guest_ip = $visitor_location['IP'];
$guest_country = $visitor_location['CountryName'];*/
$guest_ip = '0.0.0.0';
//get the ip address of the remote machine
if (Session::has('my_ip')) {
$guest_ip = Session::get('my_ip');
} else {
$guest_ip = str_random(60);
Session::put('my_ip', $guest_ip);
}
//check if the ip adress is in the devices table
$device = Device::where('ip', '=', $guest_ip);
if ($device->count()) {
//redirect to the previous page
$device = $device->first();
$campusid = $device->branch_id;
return $campusid;
} else {
//redirect to country selection page and save it on selection
return 0;
}
}
示例4: testRegisterSucess
public function testRegisterSucess()
{
$response = $this->_getResponse();
$device = Device::where('auth_key', $this->_params['auth_key'])->where('device_id', $this->_params['device_id'])->where('platform', $this->_params['platform'])->first();
$this->assertNotNull($device);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals(json_encode(array("code" => ApiResponse::OK, "data" => ApiResponse::getErrorContent(ApiResponse::OK))), $response->getContent());
}
示例5: getDevice
private function getDevice()
{
$header = Request::header('Authorization');
preg_match('#^Bearer\\s+(.*?)$#', $header, $matches);
$authToken = $matches[1];
$device = Device::where('auth_token', $authToken)->first();
return $device;
}
示例6: checkSessionId
public static function checkSessionId($input)
{
$device = Device::where('device_id', $input['device_id'])->where('session_id', $input['session_id'])->where('user_id', $input['user_id'])->first();
if (!empty($device)) {
return $input['session_id'];
}
return false;
}
示例7: getUserTokens
private function getUserTokens($userId)
{
$tokens = array();
Device::where('user_id', $userId)->get()->each(function ($device) use(&$tokens) {
$this->info("Tokens {$device->auth_token}");
$tokens[] = $device->auth_token;
});
return $tokens;
}
示例8: getOwnerToken
public function getOwnerToken()
{
$token = null;
if (isset($this->user_id) && (int) $this->user_id > 0) {
$device = Device::where('user_id', $this->user_id)->get()->first();
if ($device) {
$token = $device->auth_token;
}
}
return $token;
}
示例9: 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();
}
示例10: getRedirect
public function getRedirect($username, $id)
{
$link = Link::where('id', '=', $id)->first();
/*Get user ip address*/
$ip_address = $_SERVER['REMOTE_ADDR'];
$device = Device::where('ip', '=', $ip_address);
if (!$device->count()) {
//record the device
$user = Device::create(array('ip' => $ip_address));
$link->clicks = $link->clicks + 1;
$link_save = $link->save();
}
return Redirect::away($link->link_name);
}
示例11: getNotificationByDeviceId
/**
* Api function for get listing notifications by device id.
*
* @return mixed
*/
public function getNotificationByDeviceId()
{
$data = Input::all();
$valids = Validator::make($data, ['device_id' => 'required|alpha_dash']);
// Check validator.
if ($valids->fails()) {
return Response::json(array('status' => 'error', 'data' => $valids->messages()));
}
// Find device id.
$record = Device::where('device_id', $data['device_id'])->first();
if (!$record) {
return Response::json(array('status' => 'error', 'data' => Lang::get('dlnlab.aloexrates::message.device_not_exist')));
}
$records = Notification::where('device_id', $record->id)->get()->toArray();
return Response::json(array('status' => 'successs', 'data' => $records));
}
示例12: storeOrGet
private function storeOrGet($type, $id)
{
$user = Auth::user();
$like = $this->get($type, $id, $user->id);
if (!$like) {
$like = Like::create(['likeable_id' => $id, 'likeable_type' => $type, 'user_id' => $user->id, 'created_at' => Carbon\Carbon::now()]);
if (in_array($type, array('Post', 'Comment'))) {
$object = $type::find($id);
if ($object) {
if ($user->id != $object->user_id && ($device = Device::where('user_id', $object->user_id)->get()->first())) {
$method = "set{$type}AsLiked";
$state = new StateSender($device->auth_token);
$state->{$method}($object, Auth::user());
}
}
}
}
return $like;
}
示例13: push_notification
public static function push_notification($input)
{
$error_code = ApiResponse::OK;
$validator = Validator::make($input, array('auth_key' => 'required', 'device_id' => 'required', 'platform' => 'required'));
//validate params
if ($validator->fails()) {
$error_code = ApiResponse::MISSING_PARAMS;
$data = $input;
} else {
//check device existed
if (Device::where('auth_key', $input['auth_key'])->first() != null) {
$error_code = ApiResponse::EXISTED_DEVICE;
$data = ApiResponse::getErrorContent(ApiResponse::EXISTED_DEVICE);
} else {
$device = Device::create($input);
if ($device) {
$data = "ok";
}
}
}
return array("code" => $error_code, "data" => $data);
}
示例14: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$key = Input::get('key');
$deliverydate = Input::get('date');
/*
->join('members as m','d.merchant_id=m.id','left')
->where('assignment_date',$indate)
->where('device_id',$dev->id)
->and_()
->group_start()
->where('status',$this->config->item('trans_status_admin_courierassigned'))
->or_()
->group_start()
->where('status',$this->config->item('trans_status_new'))
->where('pending_count >', 0)
->group_end()
->group_end()
*/
$dev = \Device::where('key', '=', $key)->first();
//print_r($dev);
$txtab = \Config::get('jayon.incoming_delivery_table');
/*
$orders = $this->model
->select(
\DB::raw(
\Config::get('jayon.incoming_delivery_table').'.* ,'.
\Config::get('jayon.jayon_members_table').'.merchantname as merchant_name ,'.
\Config::get('jayon.applications_table').'.application_name as app_name ,'.
'('.$txtab.'.width * '.$txtab.'.height * '.$txtab.'.length ) as volume'
)
)
->leftJoin(\Config::get('jayon.jayon_members_table'), \Config::get('jayon.incoming_delivery_table').'.merchant_id', '=', \Config::get('jayon.jayon_members_table').'.id' )
->leftJoin(\Config::get('jayon.applications_table'), \Config::get('jayon.incoming_delivery_table').'.application_id', '=', \Config::get('jayon.applications_table').'.id' )
->where('device_id','=',$dev->id)
->where('assignment_date','=',$deliverydate)
->where(function($q){
$q->where('status','=', \Config::get('jayon.trans_status_new') )
->orWhere(function($ql){
$ql->where('status','=', \Config::get('jayon.trans_status_new') )
->where('pending_count','>',0);
});
})
->orderBy('ordertime','desc')
->get();
*/
$orders = $this->model->select(\DB::raw(\Config::get('jayon.incoming_delivery_table') . '.* ,' . \Config::get('jayon.jayon_couriers_table') . '.fullname as courier ,' . \Config::get('jayon.jayon_devices_table') . '.identifier as device ,' . \Config::get('jayon.jayon_members_table') . '.merchantname as merchant_name ,' . \Config::get('jayon.applications_table') . '.application_name as app_name ,' . '(' . $txtab . '.width * ' . $txtab . '.height * ' . $txtab . '.length ) as volume'))->leftJoin(\Config::get('jayon.jayon_couriers_table'), \Config::get('jayon.incoming_delivery_table') . '.courier_id', '=', \Config::get('jayon.jayon_couriers_table') . '.id')->leftJoin(\Config::get('jayon.jayon_devices_table'), \Config::get('jayon.incoming_delivery_table') . '.device_id', '=', \Config::get('jayon.jayon_devices_table') . '.id')->leftJoin(\Config::get('jayon.jayon_members_table'), \Config::get('jayon.incoming_delivery_table') . '.merchant_id', '=', \Config::get('jayon.jayon_members_table') . '.id')->leftJoin(\Config::get('jayon.applications_table'), \Config::get('jayon.incoming_delivery_table') . '.application_id', '=', \Config::get('jayon.applications_table') . '.id')->where(function ($query) use($deliverydate) {
/*
->where('warehouse_status','=', \Config::get('jayon.trans_status_atmerchant') )
*/
$query->where('pickup_status', '=', \Config::get('jayon.trans_status_pickup'))->where('status', '!=', \Config::get('jayon.trans_status_canceled'))->where('status', '!=', \Config::get('jayon.trans_status_mobile_delivered'))->where('ordertime', '>=', $deliverydate);
/*
->orWhere('status','=', \Config::get('jayon.trans_status_mobile_pickedup') )
->orWhere('status','=', \Config::get('jayon.trans_status_mobile_enroute') )
->orWhere(function($q){
$q->where('status', \Config::get('jayon.trans_status_new'))
->where(\Config::get('jayon.incoming_delivery_table').'.pending_count', '>', 0);
})*/
})->orderBy('ordertime', 'desc')->get();
$norders = array();
for ($n = 0; $n < count($orders); $n++) {
$or = new \stdClass();
foreach ($orders[$n] as $k => $v) {
$nk = $this->underscoreToCamelCase($k);
if (in_array($nk, $this->order_unset)) {
} else {
$or->{$nk} = is_null($v) ? '' : $v;
}
}
$or->extId = $or->id;
unset($or->id);
$bc = \Box::where('delivery_id', '=', $or->deliveryId)->count();
if ($bc == 0) {
$this->createBox($or->deliveryId, $or->merchantTransId, $or->fulfillmentCode, $or->boxCount);
}
$or->boxList = $this->boxList('delivery_id', $or->deliveryId, $key, $or->merchantId);
$or->boxObjects = $this->boxList('delivery_id', $or->deliveryId, $key, $or->merchantId, true);
$or->merchantObject = $this->merchantObject($or->merchantId);
$orders[$n] = $or;
//$norders[] = $or;
}
$actor = $key;
\Event::fire('log.api', array($this->controller_name, 'get', $actor, 'logged out'));
return $orders;
//
}
示例15: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$key = Input::get('key');
$deliverydate = Input::get('date');
$until = Input::get('until');
if (is_null($until) || $until == '') {
$until = date('Y-m-d', time());
}
/*
->join('members as m','d.merchant_id=m.id','left')
->where('assignment_date',$indate)
->where('device_id',$dev->id)
->and_()
->group_start()
->where('status',$this->config->item('trans_status_admin_courierassigned'))
->or_()
->group_start()
->where('status',$this->config->item('trans_status_new'))
->where('pending_count >', 0)
->group_end()
->group_end()
*/
$dev = \Device::where('key', '=', $key)->first();
//print_r($dev);
$txtab = \Config::get('jayon.incoming_delivery_table');
/*
$orders = $this->model
->select(
\DB::raw(
\Config::get('jayon.incoming_delivery_table').'.* ,'.
\Config::get('jayon.jayon_members_table').'.merchantname as merchant_name ,'.
\Config::get('jayon.applications_table').'.application_name as app_name ,'.
'('.$txtab.'.width * '.$txtab.'.height * '.$txtab.'.length ) as volume'
)
)
->leftJoin(\Config::get('jayon.jayon_members_table'), \Config::get('jayon.incoming_delivery_table').'.merchant_id', '=', \Config::get('jayon.jayon_members_table').'.id' )
->leftJoin(\Config::get('jayon.applications_table'), \Config::get('jayon.incoming_delivery_table').'.application_id', '=', \Config::get('jayon.applications_table').'.id' )
->where('device_id','=',$dev->id)
->where('assignment_date','=',$deliverydate)
->where(function($q){
$q->where('status','=', \Config::get('jayon.trans_status_new') )
->orWhere(function($ql){
$ql->where('status','=', \Config::get('jayon.trans_status_new') )
->where('pending_count','>',0);
});
})
->orderBy('ordertime','desc')
->get();
*/
$orders = $this->model->select(\DB::raw(\Config::get('jayon.incoming_delivery_table') . '.* ,' . \Config::get('jayon.jayon_couriers_table') . '.fullname as courier ,' . \Config::get('jayon.jayon_devices_table') . '.identifier as device ,' . \Config::get('jayon.jayon_members_table') . '.merchantname as merchant_name ,' . \Config::get('jayon.applications_table') . '.application_name as app_name ,' . '(' . $txtab . '.width * ' . $txtab . '.height * ' . $txtab . '.length ) as volume'))->leftJoin(\Config::get('jayon.jayon_couriers_table'), \Config::get('jayon.incoming_delivery_table') . '.courier_id', '=', \Config::get('jayon.jayon_couriers_table') . '.id')->leftJoin(\Config::get('jayon.jayon_devices_table'), \Config::get('jayon.incoming_delivery_table') . '.device_id', '=', \Config::get('jayon.jayon_devices_table') . '.id')->leftJoin(\Config::get('jayon.jayon_members_table'), \Config::get('jayon.incoming_delivery_table') . '.merchant_id', '=', \Config::get('jayon.jayon_members_table') . '.id')->leftJoin(\Config::get('jayon.applications_table'), \Config::get('jayon.incoming_delivery_table') . '.application_id', '=', \Config::get('jayon.applications_table') . '.id')->where(function ($query) use($deliverydate, $until) {
$query->where('pickup_status', '=', \Config::get('jayon.trans_status_tobepickup'))->where('status', '!=', \Config::get('jayon.trans_status_canceled'))->where('status', '!=', \Config::get('jayon.trans_status_mobile_delivered'))->whereBetween('ordertime', array($deliverydate . ' 00:00:00', $until . ' 23:59:59'));
//->where('ordertime','>=',$deliverydate.' 00:00:00');
/*
->orWhere('status','=', \Config::get('jayon.trans_status_mobile_pickedup') )
->orWhere('status','=', \Config::get('jayon.trans_status_mobile_enroute') )
->orWhere(function($q){
$q->where('status', \Config::get('jayon.trans_status_new'))
->where(\Config::get('jayon.incoming_delivery_table').'.pending_count', '>', 0);
})*/
})->orderBy('ordertime', 'desc')->get();
$total_billing = 0;
$total_delivery = 0;
$total_cod = 0;
$norders = array();
for ($n = 0; $n < count($orders); $n++) {
$or = new \stdClass();
foreach ($orders[$n] as $k => $v) {
$nk = $this->underscoreToCamelCase($k);
if (in_array($nk, $this->order_unset)) {
} else {
$or->{$nk} = is_null($v) ? '' : $v;
}
}
$or->extId = $or->id;
unset($or->id);
$bc = \Box::where('delivery_id', '=', $or->deliveryId)->count();
if ($bc == 0) {
$this->createBox($or->deliveryId, $or->merchantTransId, $or->fulfillmentCode, $or->boxCount);
}
$or->boxList = $this->boxList('delivery_id', $or->deliveryId, $key, $or->merchantId);
$or->boxObjects = $this->boxList('delivery_id', $or->deliveryId, $key, $or->merchantId, true);
$or->merchantObject = $this->merchantObject($or->merchantId);
/* chargeable */
$total = doubleval($or->totalPrice);
$dsc = doubleval($or->totalDiscount);
$tax = doubleval($or->totalTax);
$dc = doubleval($or->deliveryCost);
$cod = doubleval($or->codCost);
$total = is_nan($total) ? 0 : $total;
$dsc = is_nan($dsc) ? 0 : $dsc;
$tax = is_nan($tax) ? 0 : $tax;
$dc = is_nan($dc) ? 0 : $dc;
$cod = is_nan($cod) ? 0 : $cod;
//.........这里部分代码省略.........