/** * @param $id * @param array $columns * @param array $keyToInclude * * @return ParseObject */ public function find($id, $columns = ['*'], $keyToInclude = []) { for ($i = 0; $i < count($keyToInclude); $i++) { $this->query->includeKey($keyToInclude[$i]); } return $this->query->get($id, $this->useMasterKey); }
public function dtestParseBytesFromBase64Data() { $obj = ParseObject::create("TestObject"); $bytes = ParseBytes::createFromBase64Data("R3JhbnRsYW5k"); $obj->set("byteColumn", $bytes); $obj->save(); $query = new ParseQuery("TestObject"); $objAgain = $query->get($obj->getObjectId()); $this->assertEquals("Grantland", $objAgain->get("byteColumn")); }
/** * Retrieve a user by their unique identifier. * * @param mixed $identifier * * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null */ public function retrieveById($identifier) { // check current user exist $currentUser = ParseUser::getCurrentUser(); if ($currentUser->getObjectId() == $identifier) { return $currentUser; } $query = new ParseQuery('_User'); return $query->get($identifier, true); }
public function getCarsOfUsers($userObjectId) { $_user = new ParseQuery("_User"); $_user->get($userObjectId); $user = $_user->find(); $_car = new ParseQuery("Car"); $_car->equalTo("owner", $user[0]); $cars = $_car->find(); return $cars; }
public function testParseBytesFromBase64Data() { $obj = ParseObject::create('BytesObject'); $bytes = ParseBytes::createFromBase64Data('R3JhbnRsYW5k'); $obj->set('byteColumn', $bytes); $obj->save(); $query = new ParseQuery('BytesObject'); $objAgain = $query->get($obj->getObjectId()); $this->assertEquals('Grantland', $objAgain->get('byteColumn')); }
public function store(ValidateAddExpert $request) { $expert = new ParseObject("experts"); $expert->set("name", $request->get('name')); $expert->set("email", $request->get('email')); $expert->set("password", bcrypt($request->get('password'))); $cityID = $request->get('city'); $c = new ParseQuery("Cities"); $city = $c->get($cityID); $expert->set("city", $city); $expert->save(); return \Redirect::route('addExpert')->with('message', 'Expert has been created'); }
/** * Retrieve a user by their unique identifier. * * @param mixed $identifier * * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null */ public function retrieveById($identifier) { $query = new ParseQuery('_User'); try { return $query->get($identifier, true); } catch (ParseException $pex) { // Only return null if it's the object not found exception if ($pex->getCode() == self::PEX_OBJECT_NOT_FOUND) { return null; } else { throw $pex; } } }
/** * Finds the item by id and removes it. Redirects to the app (PRG) and uses the flash message to pass on any errors. */ public function deleteAction() { if (!$this->request instanceof \Zend\Http\Request or !$this->request->isPost()) { return; //nothing to do } $query = new ParseQuery(self::PARSE_CLASS); try { $item = $query->get($this->request->getPost('id')); $item->destroy(); } catch (ParseException $e) { $this->flashMessenger()->addErrorMessage($e->getMessage()); } $this->redirect()->toRoute('app'); }
private function fetchParseUser($user_id) { $query = new ParseQuery("UserObject"); $parseUser = "******"; try { $parseUser = $query->get($user_id); return $parseUser; // The object was retrieved successfully. } catch (ParseException $ex) { // The object was not retrieved successfully. // error is a ParseException with an error code and message. echo 'Kõik on katki!'; } return $parseUser; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update() { try { ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k')); $condicoesJSON = Input::get('condicoes'); $condicoes = json_decode($condicoesJSON); $protocoloId = Input::get('id'); $protocoloQuery = new ParseQuery("Protocolo"); $protocolo = $protocoloQuery->get($protocoloId); $condQuery = new ParseQuery("DescritivoMinimo"); $condQuery->equalTo('protocolo', $protocolo); $condicoesFromServer = $condQuery->find(); $condicoesArray = []; for ($serverIndex = 0; $serverIndex < count($condicoesFromServer); $serverIndex++) { $present = false; if (array_key_exists($serverIndex, $condicoesFromServer)) { $keysArray = array_keys($condicoes); for ($localIndex = 0; $localIndex < count($keysArray); $localIndex++) { if (array_key_exists($keysArray[$localIndex], $condicoes)) { if ($condicoes[$keysArray[$localIndex]]->id == $condicoesFromServer[$serverIndex]->getObjectId()) { $present = true; $condicoesFromServer[$serverIndex]->set('ordem', $condicoes[$keysArray[$localIndex]]->ordem); $condicoesFromServer[$serverIndex]->save(); $condicoesArray[$condicoes[$keysArray[$localIndex]]->ordem] = $condicoesFromServer[$serverIndex]->getObjectId(); unset($condicoes[$keysArray[$localIndex]]); } } } if ($present == false) { $condicoesFromServer[$serverIndex]->destroy(); } } } $keysArray = array_keys($condicoes); for ($index = 0; $index < count($keysArray); $index++) { $condicao = new ParseObject("DescritivoMinimo"); $condicao->set('frase', $condicoes[$keysArray[$index]]->frase); $condicao->set('ordem', $condicoes[$keysArray[$index]]->ordem); $condicao->set('protocolo', $protocolo); $condicao->save(); $condicoesArray[$condicoes[$keysArray[$index]]->ordem] = $condicao->getObjectId(); } return json_encode($condicoesArray); } catch (ParseException $error) { dd($error); return $error; } }
public function get($className, $objectId) { $query = new ParseQuery($className); try { $parseObject = $query->get($objectId); $parseObject->status = 1; return $parseObject; } catch (ParseException $e) { $this->lastError = $e; $errorObject = new stdClass(); $errorObject->status = 0; $errorObject->code = $e->getCode(); $errorObject->message = $e->getMessage(); return $errorObject; } }
public function showHome(Request $request) { $current_user = ParseUser::getCurrentUser(); if (!$current_user) { return redirect()->route('login'); } $query = ParseUser::query(); $current_user = $query->get($current_user->getObjectId()); Html\Assets::addLink(Html\Link::Css(elixir('css/default.css'))); Html\Assets::addMetaTag(Html\Meta::Tag('description', '')); $query = new ParseQuery("ChatRoom"); $query->equalTo('members', $current_user); try { $chatRooms = $query->find(); $query = new ParseQuery("Messages"); $query->containedIn("chatRoom", $chatRooms); $query->descending('createdAt'); $query->includeKey('chatRoom'); $query->includeKey('user'); $query->limit(20); $messages = $query->find(); $data = []; foreach ($messages as $message) { $chatRoom = $message->get('chatRoom'); $event = $chatRoom->get('event'); $evQuery = new ParseQuery('Events'); $evQuery->includeKey('group'); $event = $evQuery->get($event->getObjectId()); $group = $event->get('group'); $relation = $message->getRelation("asset"); $aqry = $relation->getQuery(); $assets = $aqry->find(); $temp = ['group' => $group, 'event' => $event, 'chatRoom' => $chatRoom, 'message' => ['msg' => $message, 'assets' => $assets], 'user' => $message->get('user')]; $data[] = $temp; } } catch (ParseException $ex) { // The object was not retrieved successfully. // error is a ParseException with an error code and message. echo $ex->getMessage(); } $renderData = $this->getRenderData($request); $renderData['user'] = $current_user; $renderData['activeBarTab'] = "dashboard"; $renderData['data'] = $data; return view('home', $renderData); }
public function save(Request $request) { $current_user = ParseUser::getCurrentUser(); $name = $request->input('name'); $assetId = $request->input('assetId'); $current_user->set('name', $name); try { if (!empty($assetId)) { $query = new ParseQuery("Assets"); $asset = $query->get($assetId); if (!empty($asset)) { $current_user->set('image', $asset->get('file')); } } $current_user->save(); } catch (\Exception $ex) { echo 'Failed to create new object, with error message: ' . $ex->getMessage(); } return redirect()->route('profile'); }
public function showUploader($roomId, Request $request) { $current_user = ParseUser::getCurrentUser(); if (!$current_user) { return redirect()->route('login'); } $message = $request->input('msg'); Html\Assets::addLink(Html\Link::Css('/vendor/dropzone/dropzone.css')); Html\Assets::addLink(Html\Link::Css(elixir('css/default.css'))); Html\Assets::addLink(Html\Link::Script('//www.parsecdn.com/js/parse-1.6.7.min.js')); Html\Assets::addLink(Html\Link::Script('/vendor/dropzone/dropzone.js')); Html\Assets::addLink(Html\Link::Script(elixir('scripts/chatUploader.js'))); Html\Assets::addMetaTag(Html\Meta::Tag('description', '')); $query = new ParseQuery("ChatRoom"); $chatObj = $query->get($roomId); $renderData = $this->getRenderData($request); $renderData['user'] = $current_user; $renderData['chatObj'] = $chatObj; $renderData['message'] = $message; return view('chatUploader', $renderData); }
/** * Retrieve a user by their unique identifier. * * @param mixed $identifier * * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null */ public function retrieveById($identifier) { $query = new ParseQuery('_User'); return $query->get($identifier, true); }
public function dtestUserAssociations() { $child = ParseObject::create("TestObject"); $child->save(); $user = new ParseUser(); $user->setUsername('asdf'); $user->setPassword('zxcv'); $user->set('testobject', $child); $user->signUp(); $object = ParseObject::create("TestObject"); $object->set('user', $user); $object->save(); $query = new ParseQuery("TestObject"); $objectAgain = $query->get($object->getObjectId()); $userAgain = $objectAgain->get('user'); $userAgain->fetch(); $this->assertEquals($userAgain->getObjectId(), $user->getObjectId()); $this->assertEquals($userAgain->get('testobject')->getObjectId(), $child->getObjectId()); }
public function get_application_credentials($appId, $userId) { $authority = false; $userApplications = $this->get_applications($userId); foreach ($userApplications as $app) { if ($app->id == $appId) { $authority = true; } } if ($authority == true) { $query = new ParseQuery("Organization"); $application = $query->get($appId); $credentials = array("credentials" => $application->get("credentials"), "name" => $application->get("name"), "logo" => $application->get("image"), "type" => $application->get("type")); return $credentials; } else { $error = "You are not authorized to access this application !"; return $error; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy() { try { ParseClient::initialize(env('PARSE_ID', 'f**k'), env('PARSE_REST', 'f**k'), env('PARSE_MASTER', 'f**k')); $encaminhamentoId = Input::get('id'); $encQuery = new ParseQuery("Encaminhamento"); $encaminhamento = $encQuery->get($encaminhamentoId); $encaminhamento->destroy(); return 200; } catch (ParseException $error) { return $error; } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function uncheck(Request $request) { $user = Auth::user(); if ($user) { $input = Input::all(); $query = new ParseQuery("Transaction"); $object = $query->get($input["id"]); $object->set("used", false); $object->save(); } else { return Redirect::to('login'); } }
} } } } } } // BODY // Get user $name = $user->get('fullName'); // get user's name //echo "<h1>Hi $name</h1>"; // print it // Get hackathon $CITRUS_HACK_ID = 'QpZGpVa5oc'; $query = new ParseQuery("Hackathon"); try { $currentHackathon = $query->get("QpZGpVa5oc"); // The object was retrieved successfully. } catch (ParseException $ex) { // The object was not retrieved successfully. // error is a ParseException with an error code and message. } // Get other users $query = new ParseQuery("_User"); $query->equalTo("currentHackathon", $currentHackathon); $results = $query->find(); $numberOfUsers = count($results); //echo "<h2>$numberOfUsers are online!</h2>"; foreach ($results as $result) { //echo $result->get('fullName') . "</br>"; } ?>
public function retrieveObject($objectId) { $query = new ParseQuery("Test"); try { ParseClient::$THROW_RESPONSE = true; $object = $query->get($objectId); } catch (\Exception $ex) { $msg = json_decode($ex->getMessage(), true); return $msg ? $msg : $ex->getMessage(); } }
use Parse\ParseObject; use Parse\ParseUser; use Parse\ParseQuery; use Parse\ParseException; use Parse\ParseClient; use Parse\ParseSessionStorage; // Start the session session_start(); $app_id = "kddcodGlyJ6DmGI7FihXt8BsXyOTS09Dgpj8UA49"; $rest_key = "ryU6g6D37JtDqIAnPbTq4SLNmihEIy8kSNPZxlhj"; $master_key = "Fm9X40ewplSIEDTOmYxVdCEN7ge31vgfFwScYr3y"; ParseClient::initialize($app_id, $rest_key, $master_key); if (isset($_POST["categoryId"]) && $_POST["categoryId"] != "" && isset($_POST["question"]) && $_POST["question"] != "" && strlen($_POST["question"]) <= 110 && isset($_POST["answer"]) && $_POST["answer"] != "" && strlen($_POST["answer"]) <= 255) { $query = new ParseQuery("FAQ_Category"); try { $category = $query->get($_POST["categoryId"]); $questions = $category->getRelation("Questions"); $newQuestion = new ParseObject("FAQ_Question"); $newQuestion->set("Text", $_POST["question"]); $newQuestion->set("AnswerText", $_POST["answer"]); $questions->add($newQuestion); $newQuestion->save(); $category->save(); // The object was retrieved successfully. } catch (ParseException $ex) { // The object was not retrieved successfully. setcookie("modError", $ex->getMessage()); } } else { if (!isset($_POST["categoryId"]) || $_POST["categoryId"] == "") { setcookie("modError", "Category not selected");
$catobj->set($CATEGORY, $category); $catobj->save(); } } $QA->set($ASKER_NAME, $askerName); $QA->set($ANSWERED_BY, $answeredBy); $QA->set($CATEGORY, $category); try { $QA->save(); die("<script>location.href = 'additionalComments.php'</script>"); } catch (Parse\ParseException $exc) { echo $exc->getTraceAsString() . '. Please try again'; } } else { $query = new ParseQuery("QuestionAnswer"); $QA = $query->get($qid); $question = $QA->get($QUESTION); $answer = $QA->get($ANSWER); } ?> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">Additional data</h3> </div> <div class="panel-body"> <table class="table table-bordered"> <tbody> <tr> <td> <h2>প্রশ্ন</h2> <br>
public function testDatetimeHandling() { $date = new \DateTime('2014-04-30T12:34:56.789Z'); $obj = ParseObject::create('TestObject'); $obj->set('f8', $date); $obj->save(); $query = new ParseQuery('TestObject'); $objAgain = $query->get($obj->getObjectId()); $dateAgain = $objAgain->get('f8'); $this->assertTrue($date->getTimestamp() == $dateAgain->getTimestamp()); }
public function remove(array $params = []) { $query = new ParseQuery("BrandPost"); $a = $query->get($params['id']); $a->destroy(); redirect(ADMIN_URL . 'brand_post'); $this->loadView($this->viewData); }
public function update(ValidateUploadAttraction $request, $id) { $query = new ParseQuery("attractions"); try { $attraction = $query->get($id); // $attraction = $query->equalTo("objectId",$id); // $attraction = $query->first(); $attraction->set("name", $request->get('name')); $attraction->set("type", $request->get('type')); $attraction->set("location", $request->get('location')); $attraction->set("description", $request->get('description')); $attraction->save(); return \Redirect::route('uploadAttractions')->with('message', 'Attraction has been created'); } catch (ParseException $ex) { } }
public function testRestrictedGetWithMasterKey() { $obj = ParseObject::create("TestObject"); $restrictedACL = new ParseACL(); $obj->setACL($restrictedACL); $obj->save(); $query = new ParseQuery("TestObject"); $objAgain = $query->get($obj->getObjectId(), true); $this->assertEquals($obj->getObjectId(), $objAgain->getObjectId()); }
/** * Created by PhpStorm. * User: Azim * Date: 12/13/2015 * Time: 12:56 AM */ include 'global.php'; use Parse\ParseQuery; $class = trim($_GET['class']); $type = $_GET['type']; $objectId = $_GET['objectId']; $name = $_GET['name']; $query = new ParseQuery($class); try { $object = $query->get($objectId); // The object was retrieved successfully. // print_r($object); } catch (ParseException $ex) { // The object was not retrieved successfully. // error is a ParseException with an error code and message. } if ($class == "Brand" && $type == "edit") { ?> <script type="text/javascript"> $("#save_changes").click(function(){ var Brand = Parse.Object.extend("Brand"); var query = new Parse.Query(Brand); var objectId = $("#brand_objectId").val().toString(); var name = $("#brand_name").val().toString();
public function testRoleHierarchyAndPropagation() { $eden = $this->createEden(); ParseUser::logIn('adam', 'adam'); $query = new ParseQuery('Things'); $garden = $query->get($eden['garden']->getObjectId()); ParseUser::logIn('eve', 'eve'); $garden = $query->get($eden['garden']->getObjectId()); ParseUser::logIn('snake', 'snake'); $garden = $query->get($eden['garden']->getObjectId()); $eden['edenkin']->getRoles()->remove($eden['humans']); $eden['edenkin']->save(); ParseUser::logIn('adam', 'adam'); try { $query->get($eden['garden']->getObjectId()); $this->fail('Get should have failed.'); } catch (\Parse\ParseException $ex) { if ($ex->getMessage() != 'Object not found.') { throw $ex; } } ParseUser::logIn('eve', 'eve'); try { $query->get($eden['garden']->getObjectId()); $this->fail('Get should have failed.'); } catch (\Parse\ParseException $ex) { if ($ex->getMessage() != 'Object not found.') { throw $ex; } } ParseUser::logIn('snake', 'snake'); $query->get($eden['garden']->getObjectId()); }
public function testUnsavedFileOnObjectSave() { $contents = "remember"; $file = ParseFile::createFromData($contents, "bones.txt"); $obj = ParseObject::create("TestFileObject"); $obj->set("file", $file); $obj->save(); $query = new ParseQuery("TestFileObject"); $objAgain = $query->get($obj->getObjectId()); $fileAgain = $objAgain->get("file"); $contentsAgain = $fileAgain->getData(); $this->assertEquals($contents, $contentsAgain); }