本文整理汇总了PHP中Device::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Device::create方法的具体用法?PHP Device::create怎么用?PHP Device::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device::create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testRegisterDeviceExisted
public function testRegisterDeviceExisted()
{
Device::create($this->_params);
$response = $this->_getResponse();
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals(json_encode(array("code" => ApiResponse::EXISTED_DEVICE, "data" => ApiResponse::getErrorContent(ApiResponse::EXISTED_DEVICE))), $response->getContent());
}
示例3: device_controller
function device_controller()
{
global $session, $route, $mysqli, $user, $redis;
$result = false;
require_once "Modules/device/device_model.php";
$device = new Device($mysqli, $redis);
if ($route->format == 'html') {
if ($route->action == "view" && $session['write']) {
$devices_templates = $device->get_templates();
$result = view("Modules/device/Views/device_view.php", array('devices_templates' => $devices_templates));
}
if ($route->action == 'api') {
$result = view("Modules/device/Views/device_api.php", array());
}
}
if ($route->format == 'json') {
if ($route->action == 'list') {
if ($session['userid'] > 0 && $session['write']) {
$result = $device->get_list($session['userid']);
}
} elseif ($route->action == "create") {
if ($session['userid'] > 0 && $session['write']) {
$result = $device->create($session['userid']);
}
} elseif ($route->action == "listtemplates") {
if ($session['userid'] > 0 && $session['write']) {
$result = $device->get_templates();
}
} else {
$deviceid = (int) get('id');
if ($device->exist($deviceid)) {
$deviceget = $device->get($deviceid);
if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $deviceget['userid'] == $session['userid']) {
if ($route->action == "get") {
$result = $deviceget;
}
if ($route->action == "delete") {
$result = $device->delete($deviceid);
}
if ($route->action == 'set') {
$result = $device->set_fields($deviceid, get('fields'));
}
if ($route->action == 'inittemplate') {
$result = $device->init_template($deviceid);
}
}
} else {
$result = array('success' => false, 'message' => 'Device does not exist');
}
}
}
return array('content' => $result);
}
示例4: loginSocial
public function loginSocial()
{
$input = Input::all();
$user = User::where('facebook_id', $input['facebook_id'])->where('google_id', $input['google_id'])->first();
if (!$user) {
$sessionId = generateRandomString();
$userId = User::create(['username' => $input['username'], 'facebook_id' => $input['facebook_id'], 'google_id' => $input['google_id'], 'status' => INACTIVE])->id;
Device::create(['user_id' => $userId, 'session_id' => $sessionId, 'device_id' => $input['device_id']]);
} else {
$userId = $user->id;
$sessionId = Common::getSessionId($input, $userId);
}
return Common::returnData(200, SUCCESS, $userId, $sessionId);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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;
}
示例8: add_device
public function add_device($user_id)
{
$validator = Validator::make(array('id' => $user_id), array('id' => 'numeric'));
if ($validator->fails()) {
return $this->respondInsufficientPrivileges($validator->messages()->all());
}
$user = User::find($user_id);
$devices = $user->devices->toArray();
// Check for duplicates?
$device_id = Input::get('device_id');
if (!!!$device_id) {
return $this->respondInsufficientPrivileges('Please provide a device');
}
if ($user) {
if ($device_id) {
if (in_array($device_id, $devices)) {
return $this->respondInsufficientPrivileges('User already have this device');
}
Device::create(array('user_id' => $user_id, 'device_id' => $device_id));
return $this->respondNoContent();
}
return $this->respondNotFound('Please give a device');
}
return $this->respondNotFound('User or devices not found');
}
示例9: store
/**
* Store a newly created resource in storage.
* POST /users
*
* @return Response
*/
public function store()
{
$validator = User::validate(Input::all());
$token = Input::get('token');
if ($validator->fails()) {
return $this->respondInsufficientPrivileges($validator->messages()->all());
}
$smsEntry = SMS::where('token', $token)->orderBy('id')->first();
if (!$smsEntry) {
return $this->respondInsufficientPrivileges('user.invalid-token');
}
if (!$smsEntry->verified) {
return Response::json(['error' => ['message' => 'Your number is not yet verified. Please re-register.', 'status' => 1]], 403);
}
$device = Device::create(['udid' => $smsEntry->device, 'auth_token' => base64_encode(openssl_random_pseudo_bytes(32)), 'phone' => $smsEntry->phone]);
$phone = Phone::create(['number' => $smsEntry->phone]);
$user = new User(Input::all());
if (Input::hasFile('img')) {
$user->setAvatar(Input::file('img'));
} else {
//FIXME cant get default postgres value to work
// $user->img_origin = S3_PUBLIC.'placeholder_128.png';
// $user->img_middle = S3_PUBLIC.'placeholder_128.png';
// $user->img_small = S3_PUBLIC.'placeholder_64.png';
}
$user->phone_id = $phone->id;
$user->password = Input::get('password');
$user->urgent_calls = 2;
$user->save();
$user->roles()->attach(3);
// user role
$user->devices()->save($device);
$user->phones()->save($phone);
$user->subscriptions()->attach([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 56, 57, 58]);
// Category::updateSubsCounts();
$smsEntry->delete();
$response['user'] = $this->collectionTransformer->transformUserToSmall($user);
$response['auth_token'] = $device->auth_token;
return $this->respond($response);
// Mail::send('emails.verify', ['token' => $user->verification_code], function($message) use ($user) {
// $message->to($user->email, $user->name.' '.$user->family_name)->subject('Verify your account');
// });
}
示例10: message
message('成功创建设备', $this->createWebUrl('devices'));
}
}
}
include $this->template('device-from');
}
if ($foo == 'download') {
if ($_W['ispost']) {
$api = new Api();
$device = $_GPC['device_id'];
$entity = $api->queryDevice($device);
if (!is_error($entity)) {
$r = array_elements(array('device_id', 'major', 'minor', 'status', 'uuid'), $entity);
$r['title'] = $entity['comment'];
$c = new Device();
$ret = $c->create($r);
if (is_error($ret)) {
message($ret['message']);
} else {
message('成功同步设备', $this->createWebUrl('devices'));
}
} else {
exit('设备无效或未激活');
}
}
include $this->template('device-download');
}
if ($foo == 'modify') {
$id = $_GPC['id'];
$g = new Device();
$entity = $g->getOne($id);
示例11: Validate
<?php
include "templetes/header.php";
if (Input::exists()) {
if (Token::check(Input::get('token'))) {
// echo Input::get('surname');
$validate = new Validate();
$validation = $validate->check($_POST, array('surname' => array('required' => true, 'min' => 2, 'max' => 32), 'initial' => array('min' => 1, 'max' => 1), 'first_name' => array('required' => true, 'min' => 2, 'max' => 32), 'serial_number' => array('required' => true, 'min' => 32, 'max' => 32, 'unique' => 'devices'), 'year' => array('required' => true), 'model_name' => array('required' => true), 'bgsid' => array('required' => true, 'unique' => 'devices'), 'building_name' => array('required' => true), 'building_location' => array('required' => true), 'room_number' => array('required' => true, 'unique' => 'rooms')));
if ($validation->passed()) {
$user = new User();
$model = new Model();
$device = new Device();
$building = new Building();
$room = new Room();
try {
$user->create(array('surname' => Input::get('surname'), 'initial' => Input::get('initial'), 'first_name' => Input::get('first_name')));
$device->create(array('serial_number' => Input::get('serial_number'), 'year' => Input::get('year'), 'bgsid' => Input::get('bgsid')));
$model->create(array('model_name' => Input::get('model_name')));
$building->create(array('building_name' => Input::get('building_name'), 'building_location' => Input::get('building_location')));
$room->create(array('room_number' => Input::get('room_number')));
Session::flash('registered', 'The data was send into the database successfully!');
// header('Location: index.php');
Redirect::to('index.php');
} catch (Exception $e) {
die($e->getMessage());
}
} else {
// print_r($validation->errors());
foreach ($validation->errors() as $error) {
echo $error, '<br>';
}
}
示例12: run
public function run()
{
Device::create(['device_id' => 'b7fd5c4d9ad9f0bd', 'user_id' => '1', 'session_id' => 'CH69bMxpjXQ8sjda']);
Device::create(['device_id' => '94f0be083d2a20a', 'user_id' => '2', 'session_id' => 'CtoQevz1i1u1f6mH']);
Device::create(['device_id' => '6de5427b05b10198', 'user_id' => '3', 'session_id' => 'QBAz9zXaT14Bx27I']);
}
示例13: devicesAuth
/**
* Authorize new device,
* request new access_token
* @return Response
*/
public function devicesAuth()
{
$number = Input::get('phone');
$password = Input::get('password');
$udid = Input::get('udid');
if (!Input::has('udid')) {
return $this->respondNotFound('Device id not found');
}
//TODO Validation
$phone = Phone::where('number', $number)->first();
if (!$phone) {
return $this->respondNotFound('Phone not found');
}
$user = $phone->user;
if (!$user) {
return $this->respondNotFound('User not found');
}
if ($user->checkPasswordAttribute($password)) {
$device = $user->devices()->where('udid', $udid)->first();
if ($device) {
//TODO hardcoded bad
return $this->respond(['user' => ['id' => $user->id, 'name' => $user->name, 'img' => ["thumb" => $user->img_small, "middle" => $user->img_middle, "origin" => $user->img_large]], 'auth_token' => $device->auth_token]);
} else {
$newDevice = Device::create(['udid' => $udid, 'auth_token' => base64_encode(openssl_random_pseudo_bytes(32))]);
$user->devices()->save($newDevice);
return $this->respond(['user' => ['id' => $user->id, 'name' => $user->name, 'img' => ["thumb" => $user->img_origin, "middle" => $user->img_middle, "origin" => $user->img_origin]], 'auth_token' => $newDevice->auth_token]);
}
} else {
return $this->respondInsufficientPrivileges('Wrong password');
//TODO change to 401
}
}
示例14: Event
$event = new Event();
$client = new Client();
$device = new Device();
$personnality = new Personality();
if (isset($_POST['url'])) {
$const = file_get_contents("constant.php");
file_put_contents('constant.php', preg_replace("/(define\\(\\'YANA_URL\\'\\,\\')(.*)('\\)\\;)/", "\$1" . $_POST['url'] . "\$3", $const));
}
//Création des tables SQL
$configuration->create();
$user->create();
$right->create();
$rank->create();
$section->create();
$event->create();
$device->create();
$personnality->create();
$personnality->birth();
$configuration->put('UPDATE_URL', 'http://update.idleman.fr/yana?callback=?');
$configuration->put('DEFAULT_THEME', 'default');
$configuration->put('COOKIE_NAME', 'yana');
$configuration->put('COOKIE_LIFETIME', '7');
$configuration->put('VOCAL_ENTITY_NAME', 'YANA');
$configuration->put('PROGRAM_VERSION', '3.0.6');
$configuration->put('HOME_PAGE', 'index.php');
$configuration->put('VOCAL_SENSITIVITY', '0.0');
//Création du rang admin
$rank = new Rank();
$rank->setLabel('admin');
$rank->save();
//Déclaration des sections du programme