当前位置: 首页>>代码示例>>PHP>>正文


PHP ParseObject::getRelation方法代码示例

本文整理汇总了PHP中Parse\ParseObject::getRelation方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseObject::getRelation方法的具体用法?PHP ParseObject::getRelation怎么用?PHP ParseObject::getRelation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parse\ParseObject的用法示例。


在下文中一共展示了ParseObject::getRelation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 function add()
 {
     // validators
     $this->form_validation->set_error_delimiters($this->config->item('error_delimeter_left'), $this->config->item('error_delimeter_right'));
     $this->form_validation->set_rules('user_id', lang('reservations input user_id'), 'trim');
     $this->form_validation->set_rules('team_id', lang('reservations input team_id'), 'trim');
     $this->form_validation->set_rules('match_data[date]', lang('reservations input date'), 'required|trim');
     $this->form_validation->set_rules('match_data[time]', lang('reservations input time'), 'required|trim');
     $this->form_validation->set_rules('match_data[duration]', lang('reservations input duration'), 'required|trim|numeric');
     if ($this->form_validation->run() == true) {
         $data = $this->input->post();
         // save the new user
         $reservation = new ParseObject("Reservation");
         $relationOwner = $reservation->getRelation("userId");
         $queryOwner = ParseUser::query();
         $owner = $queryOwner->get("btPTAhtpvo");
         $relationOwner->add($owner);
         $relationStatus = $reservation->getRelation("status");
         $queryStatus = new ParseQuery("ReservationStatus");
         $status = $queryStatus->get("KIzDQVJrAV");
         $relationStatus->add($status);
         $reservation->setAssociativeArray("reservationData", $data['match_data']);
         try {
             $reservation->save();
             $this->session->set_flashdata('message', 'New object created with objectId: ' . $reservation->getObjectId());
             redirect($this->_redirect_url);
         } catch (ParseException $ex) {
             // Execute any logic that should take place if the save fails.
             // error is a ParseException object with an error code and message.
             $this->session->set_flashdata('error', 'Failed to create new object, with error message: ' . $ex->getMessage());
         }
         // return to list and display message
     }
     // setup page header data
     // setup page header data
     $this->set_title(sprintf(lang('reservations title reservations'), $this->settings->site_name));
     $this->set_subtitle(lang('reservations subtitle add_reservation'));
     $data = $this->includes;
     // set content data
     $content_data = array('cancel_url' => $this->_redirect_url, 'user' => null, 'password_required' => true);
     // load views
     $data['content'] = $this->load->view('reservations/form', $content_data, true);
     $this->load->view($this->template, $data);
 }
开发者ID:angeldeejay,项目名称:backend,代码行数:44,代码来源:Reservations.php

示例2: ParseObject

 if (isset($_POST["message"]) && $_POST["message"] != "" && strlen($_POST["message"]) <= 255 && isset($_POST["inputEmail"]) && $_POST["inputEmail"] != "") {
     $ping = new ParseObject("Pings");
     $ping->set("Title", "TLC Helpdesk");
     //Auto set, we change later if need be
     $ping->set("Message", $_POST["message"]);
     //$newDate = getProperDateFormat(new DateTime());
     $date = array("__type" => "Date", "iso" => date("c"));
     $ping->setAssociativeArray("Date", $date);
     try {
         $query = new ParseQuery($class = '_User');
         $query->equalTo("username", $_POST["inputEmail"]);
         $user = $query->first();
         //print $_POST["inputEmail"]."<br>";
         //print_r($user);
         //print "Made it <br>";
         $relation = $ping->getRelation("User");
         //print "Made it 2<br>";
         //print_r($relation);
         $relation->add($user);
         //print "Made it 3<br>";
         $ping->save();
     } catch (ParseException $ex) {
         /* Should pass back a cookie with the error $ex->getMessage() */
         setcookie("modError", $ex->getMessage());
     } catch (Exception $ex) {
         /* Should pass back a cookie with the error $ex->getMessage() */
         if ($ex->getMessage() == "Cannot create a ParseRelationOperation with no objects.") {
             //I know this is not great, but the php code uses a base exception when throwing this error and not a parse exception.
             //print $ex->getMessage();
             setcookie("modError", "Email not found");
         } else {
开发者ID:CDMayberry,项目名称:PingITWeb,代码行数:31,代码来源:ping.php

示例3: getABeacon

function getABeacon(ParseObject $object)
{
    $beacon = new stdClass();
    $beacon->objectId = $object->getObjectId();
    $beacon->uuid = $object->get('UUID');
    $beacon->beaconColor = $object->get('beaconColor');
    if (count($object->getRelation("brand")->getQuery()->find()) != 0) {
        $beaconBrand = $object->getRelation("brand")->getQuery()->find();
        $beacon->brand = getABrand($beaconBrand[0]);
    } else {
        $beacon->brand = null;
    }
    $beacon->major = $object->get('major');
    $beacon->minor = $object->get('minor');
    $beacon->name = $object->get('name');
    if ($object->get('region') != null) {
        $beaconRegion = $object->get('region')->fetch();
        $beacon->region = getARegion($beaconRegion);
    } else {
        $beacon->region = null;
    }
    $beacon->type = $object->get('type');
    $beacon->createdAt = $object->getCreatedAt();
    $beacon->upadtedAt = $object->getUpdatedAt();
    return $beacon;
}
开发者ID:azimjs,项目名称:chartswell-admin,代码行数:26,代码来源:global.php

示例4: newEvent

 public function newEvent($gid, Request $request)
 {
     $current_user = ParseUser::getCurrentUser();
     if (!$current_user) {
         return redirect()->route('login');
     }
     Html\Assets::addLink(Html\Link::Css('/vendor/pickadate.js-3.5.6/lib/themes/default.css'));
     Html\Assets::addLink(Html\Link::Css('/vendor/pickadate.js-3.5.6/lib/themes/default.date.css'));
     Html\Assets::addLink(Html\Link::Css(elixir('css/default.css')));
     Html\Assets::addLink(Html\Link::Script('/vendor/pickadate.js-3.5.6/lib/picker.js'));
     Html\Assets::addLink(Html\Link::Script('/vendor/pickadate.js-3.5.6/lib/picker.date.js'));
     Html\Assets::addLink(Html\Link::Script(elixir('scripts/newevent.js')));
     Html\Assets::addMetaTag(Html\Meta::Tag('description', ''));
     $st = $request->input("st");
     $query = new ParseQuery("Groups");
     try {
         $group = $query->get($gid);
         //--save start
         if ($request->getMethod() == "POST") {
             $eventName = $request->input('name');
             $eventDate = $request->input('eventDate');
             $invites = $request->input('invites');
             $update = false;
             $id = $request->input('id');
             if (!empty($id)) {
                 $qry = new ParseQuery('Events');
                 $eventObj = $qry->get($id);
                 $update = true;
             } else {
                 $eventObj = new ParseObject('Events');
             }
             $eventObj->set('name', $eventName);
             if (!empty($eventDate)) {
                 $eventDate = new \DateTime($eventDate);
                 $eventObj->set('date', $eventDate);
             }
             if (empty($eventObj->get('inviteCode'))) {
                 $eventObj->set('inviteCode', $this->generate_random_letters(6));
             }
             if (empty($invites)) {
                 $invites = [];
             }
             $eventObj->setArray('invites', $invites);
             $eventObj->set('user', $current_user);
             $eventObj->set('group', $group);
             try {
                 $eventObj->save();
                 if ($update == false) {
                     $relation = $eventObj->getRelation('members');
                     $relation->add($current_user);
                     $eventObj->save();
                     $grelation = $group->getRelation('events');
                     $grelation->add($eventObj);
                     $group->save();
                     //-- create chat room --//
                     $chatObj = new ParseObject('ChatRoom');
                     $chatObj->set('name', $eventObj->get('name'));
                     $chatObj->set('event', $eventObj);
                     $chatObj->save();
                     $relation = $chatObj->getRelation('members');
                     $relation->add($current_user);
                     $chatObj->save();
                     $eventObj->set('chatRoom', $chatObj);
                     $eventObj->save();
                 }
                 return redirect('/groups');
             } catch (ParseException $ex) {
                 // Execute any logic that should take place if the save fails.
                 // error is a ParseException object with an error code and message.
                 echo 'Failed to create new object, with error message: ' . $ex->getMessage();
             }
         }
         //--save end
         $renderData = $this->getRenderData($request);
         $renderData['user'] = $current_user;
         $renderData['navTitle'] = $group->get('name');
         $renderData['st'] = !empty($st) ? $st : '';
         return view('newevent', $renderData);
     } catch (ParseException $ex) {
         // The object was not retrieved successfully.
         // error is a ParseException with an error code and message.
         echo $ex->getMessage();
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:84,代码来源:EventController.php

示例5: ParseObject

<?php

include '../files/global.php';
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseFile;
$post_message = "";
if (isset($_POST['submit_beacon'])) {
    $beacon = new ParseObject("Beacon");
    $brandQuery = new ParseQuery("Brand");
    $beacon_brand = $brandQuery->get($_POST['beacon_brand']);
    //    print_r($beacon_brand);
    $relation = $beacon->getRelation("brand");
    $relation->add($beacon_brand);
    $regionQuery = new ParseQuery("Region");
    $beacon_region = $regionQuery->get($_POST['beacon_region']);
    $beacon->set("UUID", $_POST['beacon_uuid']);
    $beacon->set("major", intval($_POST['beacon_major']));
    $beacon->set("minor", intval($_POST['beacon_minor']));
    $beacon->set("name", $_POST['beacon_name']);
    $beacon->set("region", $beacon_region);
    $beacon->set("type", $_POST['beacon_type']);
    //    print_r($beacon);
    try {
        $beacon->save();
        //        echo 'New object created with objectId: ' . $beacon->getObjectId();
    } catch (ParseException $ex) {
        // Execute any logic that should take place if the save fails.
        // error is a ParseException object with an error code and message.
        //        echo 'Failed to create new object, with error message: ' . $ex->getMessage();
    }
开发者ID:azimjs,项目名称:chartswell-admin,代码行数:31,代码来源:add_beacons.php

示例6: processGroup

 public function processGroup(Request $request)
 {
     //if logged process otherwise go to login form
     $current_user = ParseUser::getCurrentUser();
     if (!empty($current_user)) {
         //process form
         $lastAction = $request->session()->get('lastAction');
         $groupName = $request->input('groupname') ?: $request->session()->get('newgroup:groupName');
         $invites = $request->input('invites') ?: $request->session()->get('newgroup:invites');
         $public = $request->input('public') ?: $request->session()->get('newgroup:public');
         $reroute = $request->input('reroute');
         $st = $request->input('st');
         $groupId = $request->input('id');
         if (!empty($groupId)) {
             //does this user have permission to edit group
             $qry = new ParseQuery('Groups');
             $groupObj = $qry->get($groupId);
             if ($groupObj->get('public') !== true) {
                 if ($current_user->getObjectId() != $groupObj->get('user')->getObjectId()) {
                     throw new HttpException(401, 'Sorry you don\'t have permission to edit group');
                 }
             }
         } else {
             $groupObj = new ParseObject('Groups');
         }
         $groupObj->set('name', $groupName);
         $groupObj->set('user', $current_user);
         if ($public == 'y') {
             $groupObj->set('public', true);
         } else {
             $groupObj->set('public', false);
         }
         if (empty($invites)) {
             $invites = [];
         }
         $invites = array_keys(array_flip($invites));
         $prevInvites = $groupObj->get('invites') ?: array();
         $diffInvites = array_diff($invites, $prevInvites);
         $groupObj->setArray('invites', $invites);
         if (empty($groupObj->get('inviteCode'))) {
             $groupObj->set('inviteCode', $this->generate_random_letters(6));
         }
         try {
             $groupObj->save();
             $relation = $groupObj->getRelation('members');
             $relation->add($current_user);
             $groupObj->save();
             //send email
             if (!empty($diffInvites)) {
                 $send = new Mail\Send();
                 $send->sendInviteEmail($diffInvites, $current_user, $groupObj->get('inviteCode'), $groupObj->get('name'));
             }
             if ($reroute == 'newevents') {
                 $url = route('newEvent', ['gid' => $groupObj->getObjectId()]) . '?st=' . $st;
                 return redirect($url);
             } else {
                 return redirect('/groups');
             }
         } catch (ParseException $ex) {
             // Execute any logic that should take place if the save fails.
             // error is a ParseException object with an error code and message.
             echo 'Failed to create new object, with error message: ' . $ex->getMessage();
         }
     } else {
         //save form show login
         $request->session()->set('lastAction', 'newgroup');
         $request->session()->set('newgroup:groupName', $request->input('groupname'));
         $request->session()->set('newgroup:invites', $request->input('invites'));
         $request->session()->set('newgroup:public', $request->input('public'));
         return redirect()->route('register');
     }
 }
开发者ID:samphomsopha,项目名称:codelab,代码行数:72,代码来源:GroupController.php


注:本文中的Parse\ParseObject::getRelation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。