public function addTask(Request $request)
 {
     $parseTask = new ParseObject("Task");
     $parseCropQuery = new ParseQuery("Crop");
     $parseCropQuery->equalTo("cropName", $request->input('crop'));
     $crop = $parseCropQuery->first();
     $parseQuery = new ParseQuery("Task");
     $parseQuery->equalTo("cropName", $crop);
     $parseQuery->equalTo("taskDesc", $request->input('taskName'));
     if ($parseQuery->count() > 0) {
         return redirect('/tasks');
     }
     $parseTask->set("cropName", $crop);
     $parseTask->set("taskDesc", $request->input('taskName'));
     $parseTask->set("taskDuration", $request->input('taskDuration'));
     $parseTask->set("taskStart", $request->input('taskStart'));
     try {
         $parseTask->save();
         \Session::put('message', 1);
         return redirect('tasks');
     } catch (ParseException $e) {
         \Session::put('message', -1);
         return redirect('tasks');
     }
 }
 public function operators()
 {
     $query = new ParseQuery("_User");
     $query->equalTo("isOperator", true);
     $results["operators"] = $query->find();
     return $results;
 }
Exemple #3
0
 public function getUserCompanies($user)
 {
     $query = new ParseQuery(self::$parseClassName);
     $query->equalTo("users", $user);
     $results = $query->find();
     return $results;
 }
Exemple #4
0
 public function getById($objectId)
 {
     $query = new ParseQuery($this->getClassName());
     $query->equalTo('objectId', $objectId);
     $results = $query->first();
     return $results;
 }
Exemple #5
0
function getSleepers()
{
    $query = new ParseQuery("BagTransaction");
    $query->equalTo("status", "active");
    $results = $query->find();
    return $results;
}
Exemple #6
0
function getSeekers()
{
    $query = new ParseQuery("_User");
    $query->equalTo("seeking", true);
    $results = $query->find();
    return $results;
}
 public static function clearClass($class)
 {
     $query = new ParseQuery($class);
     $query->each(function (ParseObject $obj) {
         $obj->destroy(true);
     }, true);
 }
 public function query()
 {
     //iniciamos una consulta para recibir todos los usuarios ausentes de la sede del mentor logueado
     $query = new ParseQuery("Asistencia");
     $query->equalTo('Sede', array("__type" => "Pointer", "className" => "Sedes", "objectId" => $_SESSION['sede']));
     $query->includeKey('Usuario_FK');
     $results = $query->find();
     $listado = array();
     for ($i = 0; $i < count($results); $i++) {
         $object = $results[$i];
         $usuario = $object->get('Usuario_FK');
         $persona = array("ID" => $object->getObjectId(), 'Nombre' => $usuario->get("Nombre"), "Apellido" => $usuario->get("Apellido"), "Presente" => $object->get("Presente"));
         array_push($listado, $persona);
     }
     //definimos una función para ordenar el array con nuestros parámetros
     function custom_sort($a, $b)
     {
         return $a['Nombre'] > $b['Nombre'];
     }
     //ordenamos el array
     usort($listado, "custom_sort");
     //transformamos a json
     $json = json_encode($listado);
     echo $json;
 }
Exemple #9
0
 public function __construct($objectId = null)
 {
     parent::__construct("Camera", $objectId, false);
     $query = new ParseQuery("Camera");
     $query->equalTo("objectId", $objectId);
     $this->_cam = $query->first();
 }
 public function getQuery()
 {
     $query = new ParseQuery(Constant::$CLIENT_CONTACT_INFO_CLASS_NAME);
     //        $query->equalTo(Constant::$KEY_FIRST_NAME, $firstName);
     $query->descending("createdAt");
     $results = $query->find();
     return $results;
 }
 /**
  * Retrieve a user by the given credentials.
  *
  * @param  array $credentials
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable|\LaraParse\Subclasses\User|null
  * @throws \Exception
  * @throws \Parse\ParseException
  */
 public function retrieveByCredentials(array $credentials)
 {
     $username = $this->getUsernameFromCredentials($credentials);
     $query = new ParseQuery('_User');
     $query->equalTo('username', $username);
     $user = $query->first(true);
     return empty($user) ? null : $user;
 }
Exemple #12
0
 public function traerNoticiasSeccion($seccion)
 {
     $query = new ParseQuery("noticias");
     $query->descending("fecha");
     $query->equalTo("seccion", $seccion);
     $results = $query->find();
     return $results;
 }
Exemple #13
0
function getAllRestaurantsAround()
{
    try {
        $query = new ParseQuery("Restaurant");
        $results = $query->find();
    } catch (ParseException $ex) {
        echo $ex;
    }
    return $results;
}
 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;
 }
Exemple #15
0
 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"));
 }
Exemple #16
0
 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'));
 }
Exemple #17
0
function getStolenBikes()
{
    $query = new ParseQuery("Bikes");
    $query->exists("sessionStartTime");
    $query->limit(1000);
    $results = $query->find();
    $count = count($results);
    $listOfBikes = array();
    $stolenBikes = 0;
    for ($i = 0; $i < $count; $i++) {
        $startDate = $results[$i]->get("sessionStartTime");
        $startDate = $startDate->format('Y-m-d H:i:s');
        $startDate = strtotime($startDate);
        $currentDate = new DateTime('now');
        $currentDate = $currentDate->format('Y-m-d H:i:s');
        $currentDate = strtotime($currentDate);
        $subtractedDate = $currentDate - $startDate;
        $expiredTime = 200 * 60;
        if ($subtractedDate >= $expiredTime * 60) {
            $stolenBikes++;
            $bike = $results[$i];
            try {
                $lostBike = new ParseObject("LostBikes");
                $lostBike->set("bikeId", $bike->getObjectId());
                $user = $bike->get("currentUser");
                $user->fetch();
                $customerID = $user->get("stripeID");
                $amount = 200 * 100;
                $charge = \Stripe\Charge::create(array('customer' => $customerID, 'amount' => $amount, 'currency' => 'usd'));
                $lostBike->set("currentUser", $user);
                $lostBike->set("lastLocation", $bike->get("lastLocation"));
                $lostBike->set("condition", $bike->get("condition"));
                $lostBike->save();
                $bike->destroy();
            } catch (\Parse\ParseException $ex) {
                return 'Failed to create LostBikes object and destroy Bikes object ' . $ex->getMessage();
            } catch (\Stripe\Error\InvalidRequest $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\Authentication $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\ApiConnection $e) {
                return $e->getMessage();
            } catch (\Stripe\Error\Base $e) {
                return $e->getMessage();
            } catch (Exception $e) {
                return $e->getMessage();
            }
        }
    }
    $rString = 0;
    if ($stolenBikes > 0) {
        $rString = "Successfully removed " . $stolenBikes . " stolen bikes.";
    }
    return $rString;
}
Exemple #18
0
function getAllResourcesFromCacheOrQuery()
{
    global $cache;
    $resources = $cache->get("all_resource");
    if ($resources == null) {
        $query = new ParseQuery("Resource");
        $resources = $query->find();
        $cache->set("all_resource", $resources, 1800);
    }
    return $resources;
}
 public function information()
 {
     $om = new ParseObject("OmOpenMenu", "oGBLMAeTPO");
     $query = new ParseQuery("OmRi");
     $query->equalTo("omID", $om);
     $results = $query->find();
     // Get a specific object:
     $data['information'] = $results[0];
     $data['singleView'] = true;
     $this->render('restaurant/information', $data);
 }
Exemple #20
0
function getAllOrganizationFromCacheOrQuery()
{
    global $cache;
    $organizations = $cache->get("all_organization");
    if ($resources == null) {
        $query = new ParseQuery("Organization");
        $organizations = $query->find();
        $cache->set("all_organization", $resources, 1800);
    }
    return $organizations;
}
function getAllEventFromCacheOrQuery()
{
    global $cache;
    $results = $cache->get("all_event");
    if ($results == null) {
        $query = new ParseQuery("Event");
        $results = $query->find();
        //cache 15 minute
        $cache->set("all_event", $results, 900);
    }
    return $results;
}
 public function getReports()
 {
     $query = new ParseQuery("ReportOperator");
     $query->includeKey("user");
     $query->includeKey("operator");
     $results["reports"] = $query->find();
     // for ($i = 0; $i < count($results); $i++) {
     // 	$usernames = $results[$i]->get("username");
     // }
     // die("<pre>".print_r($results, true));
     return $results;
 }
 public function getAllRatings()
 {
     try {
         $_rate = new ParseQuery("OperatorRatings");
         $rate = $_rate->includeKey("user")->includeKey("operator")->find();
         return $rate;
     } catch (ParseException $px) {
         $array_px = array("Message" => $px->getMessage(), "Code" => $px->getCode());
         die('<pre>' . print_r($array_px, true));
         // return $array_px;
     }
 }
Exemple #24
0
 public function ventasDiaTotales($fecha)
 {
     $query = new ParseQuery("facturas");
     $query->startsWith("fecha", $fecha);
     $results = $query->find();
     $data['facturas'] = '';
     //print_r($results[0]->folio);
     foreach ($results as $record) {
         echo $record->serie . $record->folio;
     }
     $this->load->view('reportes/ventas_dia', $data);
 }
Exemple #25
0
 public function getAll()
 {
     $query = new ParseQuery("todo");
     $results = $query->find();
     $resposnse = [];
     foreach ($results as $result) {
         $object = new \stdClass();
         $object->completed = $result->get('completed');
         $object->id = $result->getObjectId();
         $object->title = $result->get('title');
         $resposnse[] = $object;
     }
     return $resposnse;
 }
Exemple #26
0
 public function eliminar()
 {
     $id = Input::get('id');
     $curso = Curso::find($id);
     $curso->delete();
     $query = new ParseQuery("cursos");
     $query->equalTo("myid", 14);
     $results = $query->find();
     //echo "Successfully retrieved " . count($results) . " scores.";
     // Do something with the returned ParseObject values
     for ($i = 0; $i < count($results); $i++) {
         $object = $results[$i];
         $object->destroy();
     }
 }
Exemple #27
0
 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;
 }
Exemple #28
0
 /**
  * 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');
 }
 /**
  * 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;
     }
 }
 /**
  * Apply filter settings to the source
  *
  * @param array $settings
  */
 protected function processFilters(array $settings = [])
 {
     foreach ($settings['filters'] as $column => $filter) {
         switch (key($filter)) {
             case Grid\Grid::FILTER_EQ:
                 $this->source->equalTo($column, reset($filter));
                 break;
             case Grid\Grid::FILTER_LIKE:
                 $this->source->startsWith($column, reset($filter));
                 break;
             default:
                 // throw NotImplemented?
                 break;
         }
     }
 }