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


PHP Entity::where方法代码示例

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


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

示例1: getSearchFieldsAndValues

 public function getSearchFieldsAndValues($format, $domain)
 {
     $fields = array();
     $fields['formats'] = array("text", "image", "video");
     if (is_null($format)) {
         $domains = Entity::distinct('domain')->get();
         $usersInvolvedInEntities = array_flatten(Entity::distinct('user_id')->get()->toArray());
     } else {
         $domains = Entity::where('format', $format)->distinct('domain')->get();
         $usersInvolvedInEntities = array_flatten(Entity::where('format', $format)->distinct('user_id')->get()->toArray());
         if ($key = array_search($format, $fields['formats'])) {
             $value = $fields['formats'][$key];
             unset($fields['formats'][$key]);
             array_unshift($fields['formats'], $value);
         }
     }
     if (is_null($domain)) {
         $documentTypes = Entity::where('format', $format)->distinct('documentType')->get();
     } else {
         $documentTypes = Entity::where('format', $format)->where('domain', $domain)->distinct('documentType')->get();
         $usersInvolvedInEntities = array_flatten(Entity::where('format', $format)->where('domain', $domain)->distinct('user_id')->get()->toArray());
     }
     foreach ($usersInvolvedInEntities as $key => $user_id) {
         $fields['userAgents'][$key] = User::find($user_id);
     }
     $fields['domains'] = array_flatten($domains->toArray());
     $fields['documentTypes'] = array_flatten($documentTypes->toArray());
     return $fields;
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:29,代码来源:Repository.php

示例2: getWorkerunitdata

 public function getWorkerunitdata($action = null)
 {
     if (is_null($action)) {
         $entities = Entity::where('documentType', 'csvresult')->where('title', 'like', '%workerunit%')->get();
         if (count($entities) > 0) {
             return View::make('preprocess.csvresult.pages.workerunitdata', compact('entities'));
         }
         return Redirect::to('files/upload')->with('flashNotice', 'You have not uploaded any "csvresult" documents yet');
     } elseif ($action == "preview") {
         if ($URI = Input::get('URI')) {
             if ($entity = $this->repository->find($URI)) {
                 if ($entity->documentType == "csvresult") {
                     return $document = $this->csvresultMapper->processWorkerunitData($entity, true);
                 }
             }
         }
     } elseif ($action == "process") {
         if ($URI = Input::get('URI')) {
             if ($entity = $this->repository->find($URI)) {
                 if ($entity->documentType == "csvresult") {
                     return $document = $this->csvresultMapper->processWorkerunitData($entity);
                 }
             }
         }
     }
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:26,代码来源:CSVresultController.php

示例3: getProcess

 public function getProcess()
 {
     if ($URI = Input::get('URI')) {
         if ($entity = $this->repository->find($URI)) {
             if ($entity->documentType != "fullvideo") {
                 continue;
             }
             $videoPreprocessing = $this->fullvideoStructurer->process($entity);
             $status_processing = $this->fullvideoStructurer->store($entity, $videoPreprocessing);
             if (isset($status_processing["keyframes"])) {
                 if (!isset($status_processing["keyframes"]['error'])) {
                     //update the parent
                     Entity::where('_id', '=', $entity->_id)->update(array('keyframes.count' => $status_processing["keyframes"]['success']["noEntitiesCreated"]));
                 }
                 echo "<pre>";
             }
             if (isset($status_processing["segments"])) {
                 if (!isset($status_processing["segments"]['error'])) {
                     //update the parent
                     Entity::where('_id', '=', $entity->_id)->update(array('segments.count' => $status_processing["segments"]['success']["noEntitiesCreated"]));
                 }
                 echo "<pre>";
             }
             if (isset($status_processing["keyframes"]['success']) && isset($status_processing["segments"]['success'])) {
                 return Redirect::back()->with('flashSuccess', 'Your video has been pre-processed in keyframes and video segments');
             } else {
                 return Redirect::back()->with('flashError', 'An error occurred while the video was being pre-processed in keyframes and video segments');
             }
         }
     } else {
         return Redirect::back()->with('flashError', 'No valid URI given: ' . $URI);
     }
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:33,代码来源:FullvideoController.php

示例4: getActions

 public function getActions()
 {
     // get all uploaded documents
     // TODO: change to select by actual type
     $entities = Entity::where('activity_id', 'LIKE', '%fileuploader%')->get();
     if (count($entities) > 0) {
         return View::make('media.preprocess.relex.pages.actions', compact('entities'));
     }
     return Redirect::to('media/upload')->with('flashNotice', 'You have not uploaded any documents yet');
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:10,代码来源:RelexController.php

示例5: fire

 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     // check if the provided user exists
     $user = User::where('username', '=', $this->option('user'))->first();
     if (!isset($user)) {
         $this->comment("This user don't exist.");
         return;
     }
     // check if the provided amenity exists and delete it
     $amenity = Entity::where('type', '=', 'amenity')->where('name', '=', $this->argument('name'))->where('user_id', '=', $user->id)->first();
     if (isset($amenity)) {
         $amenity->delete();
         $this->info("Amenity '{$amenity->name}' has been deleted.");
     } else {
         $this->comment("This amenity do not exist.");
     }
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:22,代码来源:DeleteAmenity.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $user = User::where('username', '=', $this->option('user'))->first();
     if (!isset($user)) {
         $this->comment("This user don't exist.");
         return;
     }
     // get thing's name
     do {
         $valid = true;
         $name = $this->ask("Name : ");
         if (empty($name)) {
             $this->comment("Your name is empty");
             $valid = false;
         }
         if (Entity::where('name', '=', $name)->where('user_id', '=', $user->id)->first() != null) {
             $this->comment("A thing with this name already exist.");
             $valid = false;
         }
     } while (!$valid);
     // get thing's type
     do {
         $type = $this->ask("Type (i.e. room) : ");
         if (empty($type)) {
             $this->comment("Your type is empty");
         }
     } while (empty($type));
     // get thing's description
     do {
         $description = $this->ask("Description : ");
         if (empty($description)) {
             $this->comment("Your description is empty");
         }
     } while (empty($description));
     // get thing's opening hours
     $opening_hours = array();
     $this->info("\t{$name} - schedule");
     $add = $this->ask("\t\tAdd opening days ? Y/n") == "Y" ? 1 : 0;
     while ($add) {
         do {
             $day = $this->ask("\t\tDay of week : ");
             if ($day < 1 || $day > 7) {
                 $this->comment("\t\tYour day must be an integer between 1 and 8.");
             }
         } while ($day < 1 || $day > 7);
         do {
             do {
                 $valid_from = strtotime($this->ask("\t\tValid from (d-m-Y) : "));
                 if (empty($valid_from)) {
                     $this->comment("\t\tYour date is empty");
                 }
                 if ($valid_from < time()) {
                     $this->comment("\t\tYour valid from value is before now");
                 }
             } while (empty($valid_from) || $valid_from < time());
             do {
                 $valid_through = strtotime($this->ask("\t\tValid through (d-m-Y) : "));
                 if (empty($valid_through)) {
                     $this->comment("\t\tYour date is empty");
                 }
                 if ($valid_through < time()) {
                     $this->comment("\t\tYour valid through value is before now");
                 }
             } while (empty($valid_through) || $valid_through < time());
             if ($valid_from > $valid_through) {
                 $this->comment("\t\tYour valid through date is before valid from date.");
             }
         } while ($valid_from > $valid_through);
         $opens = array();
         $closes = array();
         $this->info("\t\t\t{$name} - schedule [day {$day} - opening hours]");
         do {
             do {
                 $valid = true;
                 $open_close = $this->ask("\t\t\t\tOpening / Closing hour (H:m - H:m) : ");
                 $open_close = explode("-", $open_close);
                 if (count($open_close) < 2) {
                     $this->comment("\t\t\t\tYour opening closing hours are not valid");
                     $valid = false;
                 }
                 if (!preg_match("/(2[0-3]|[01][0-9]):[0-5][0-9]/", $open_close[0])) {
                     $this->comment("\t\t\t\tYour opening hour is not valid.");
                     $valid = false;
                 }
                 if (!preg_match("/(2[0-3]|[01][0-9]):[0-5][0-9]/", $open_close[1])) {
                     $this->comment("\t\t\t\tYour closing hour is not valid.");
                     $valid = false;
                 }
             } while (!$valid);
             array_push($opens, $open_close[0]);
             array_push($closes, $open_close[1]);
             $add = $this->ask("\t\t\tAdd opening hours ? Y/n") == "Y" ? 1 : 0;
         } while ($add);
         array_push($opening_hours, array('validFrom' => date('c', $valid_from), 'validThrough' => date('c', $valid_through), 'dayOfWeek' => $day, 'opens' => $opens, 'closes' => $closes));
         $add = $this->ask("\t\tAdd opening day ? Y/n") == "Y" ? 1 : 0;
//.........这里部分代码省略.........
开发者ID:tallcoder,项目名称:Reservations,代码行数:101,代码来源:AddThing.php

示例7: setMailFlag

 private function setMailFlag($mailUids, $flag, $value = false)
 {
     foreach ($mailUids as $mailUid) {
         $mailEntity = Entity::where('uid', '=', $mailUid)->first();
         if ($mailEntity) {
             switch ($flag) {
                 case "\\Seen":
                     $mailEntity->seen = $value;
                     break;
                 case "\\Sent":
                     $mailEntity->sent = $value;
                     break;
                 case "\\Flagged":
                     $mailEntity->flagged = $value;
                     break;
                 case "\\Deleted":
                     $mailEntity->deleted = $value;
                     break;
             }
             $mailEntity->save();
         }
     }
 }
开发者ID:davin-bao,项目名称:mailbox,代码行数:23,代码来源:LocaleMailbox.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $user = User::where('username', '=', $this->option('user'))->first();
     if (!isset($user)) {
         $this->comment("This user don't exist.");
         return;
     }
     //get things available for reservation and display them
     $things = Entity::where('type', '!=', 'amenity')->where('user_id', '=', $user->id)->get();
     if (!count($things)) {
         $this->comment("There is nothing to be reserved.");
         return;
     }
     foreach ($things as $thing) {
         $this->info("{$thing->name} [{$thing->id}]");
     }
     do {
         $present = false;
         // ask user which thing he wants to book
         $thing_id = $this->ask("Thing id : ");
         if (empty($thing_id)) {
             $this->comment("Your thing id is invalid");
         } else {
             for ($i = 0; $i < count($things); $i++) {
                 if ($things[$i]->id == $thing_id) {
                     $present = true;
                     $thing = $things[$i];
                 }
             }
             if (!$present) {
                 $this->comment("Your thing id is invalid");
             }
         }
     } while (empty($thing_id) || !$present);
     // get reservation's subject
     do {
         $subject = $this->ask("Subject : ");
         if (empty($subject)) {
             $this->comment("Your subject is invalid");
         }
     } while (empty($subject));
     // get reservation's comment
     do {
         $comment = $this->ask("Comment : ");
         if (empty($comment)) {
             $this->comment("Your comment is invalid.");
         }
     } while (empty($comment));
     //get reservation's timing
     do {
         $available = 1;
         do {
             $valid = true;
             $from = strtotime($this->ask("From (d-m-Y H:m) : "));
             if (empty($from)) {
                 $valid = false;
                 $this->comment("Your value is empty.");
             }
             if ($from < time()) {
                 $valid = false;
                 $this->comment("Your reservation can't start before now.");
             }
         } while (!$valid);
         do {
             $valid = true;
             $to = strtotime($this->ask("To (d-m-Y H:m) : "));
             if (empty($to)) {
                 $valid = false;
                 $this->comment("Your value is empty.");
             }
             if ($to < $from) {
                 $valid = false;
                 $this->comment("Your reservation can't end before it start.");
             }
             $thing_body = json_decode($thing->body);
         } while (!$valid);
         if (!$this->isAvailable($thing_body->opening_hours, array('from' => $from, 'to' => $to))) {
             $available = 0;
             $this->comment('The thing is not available at that time');
         }
     } while (!$available);
     //TODO(qkaiser) : verify if room is available
     // get reservation's announcement
     $announce = explode(",", $this->ask("Announce (names separated by a comma) : "));
     // create reservation object and save it to database
     $reservation = new Reservation();
     $reservation->user_id = $user->id;
     $reservation->entity_id = $thing_id;
     $reservation->subject = $subject;
     $reservation->comment = $comment;
     $reservation->from = $from;
     $reservation->to = $to;
     if (!count($announce[0])) {
         $announce = array();
     }
//.........这里部分代码省略.........
开发者ID:tallcoder,项目名称:Reservations,代码行数:101,代码来源:AddReservation.php

示例9: listRecords

 public function listRecords($parameters, $noEntries, &$listOfRecords)
 {
     $curlRequest = new SVRequest();
     $url = $this->url . "verb=ListRecords";
     if (isset($parameters)) {
         if (!array_key_exists("metadataPrefix", $parameters)) {
             if (!array_key_exists("resumptionToken", $parameters)) {
                 throw new Exception("Request must contain -metadataPrefix- parameter!");
             } else {
                 foreach ($parameters as $param => $value) {
                     $url .= "&" . $param . "=" . $value;
                 }
             }
         } else {
             foreach ($parameters as $param => $value) {
                 $url .= "&" . $param . "=" . $value;
             }
         }
     } else {
         throw new Exception('Request parameters missing!');
     }
     $entities = Entity::where('documentType', 'tv-news-broadcasts')->lists("title");
     while ($noEntries > 0) {
         //throw new Exception($noEntries);
         $result = $curlRequest->curlRequest($url, "POST", null);
         $xml = simplexml_load_string($result["result"]);
         if ($xml === false) {
             die('Error parsing XML');
         } else {
             $xmlNode = $xml->ListRecords;
             if (isset($xmlNode)) {
                 foreach ($xmlNode->record as $rNode) {
                     if (strpos((string) $rNode->metadata->children('oai_oi', 1)->oi->children('oi', 1)->type, "Moving Image") !== false) {
                         if ($noEntries > 0) {
                             if (!in_array((string) $rNode->header->identifier, $entities)) {
                                 array_push($listOfRecords, (string) $rNode->header->identifier);
                                 array_push($entities, (string) $rNode->header->identifier);
                                 //	dd($entities);
                                 $noEntries--;
                             } else {
                                 continue;
                             }
                         } else {
                             break;
                         }
                     }
                 }
             }
             if (isset($xml->ListRecords->resumptionToken)) {
                 if ($noEntries > 0) {
                     if (!array_key_exists("resumptionToken", $parameters)) {
                         $parameters["resumptionToken"] = (string) $xml->ListRecords->resumptionToken;
                         unset($parameters["metadataPrefix"]);
                         $this->listRecords($parameters, $noEntries, $listOfRecords);
                     } else {
                         $replacement = array("resumptionToken" => (string) $xml->ListRecords->resumptionToken);
                         $parameters = array_replace($parameters, $replacement);
                         $this->listRecords($parameters, $noEntries, $listOfRecords);
                     }
                 }
             }
         }
     }
     //	dd($listOfRecords);
     //	return $listOfRecords;
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:66,代码来源:OnlineData.php

示例10: createJobCache

 public static function createJobCache()
 {
     \Session::flash('rawArray', 1);
     $db = \DB::getMongoDB();
     $db = $db->temp;
     $result = Entity::where('type', 'job')->with('hasConfiguration')->get()->toArray();
     if (count($result) > 0) {
         try {
             Temp::where('type', 'job')->forceDelete();
             $db->batchInsert($result, array('continueOnError' => true));
         } catch (Exception $e) {
             // ContinueOnError will still throw an exception on duplication, even though it continues, so we just move on.
         }
     }
     \Session::forget('rawArray');
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:16,代码来源:Temp.php

示例11: array

									<?php 
// Get a list of titles and template types which are already in the database
// and put them to dropdown
$aTitles = array(null => '---');
$aTypes = array(null => '---');
$_format = unserialize(Session::get('batch'))->format;
$batchUnits = unserialize(Session::get('batch'))->parents;
$batchUnitContent = Entity::where("_id", $batchUnits[0])->get()->first();
$unitAttributes = array();
$c = array_change_key_case(array_dot($batchUnitContent['content']), CASE_LOWER);
foreach ($c as $key => $val) {
    $key = strtolower(str_replace('.', '_', $key));
    $unitAttributes[$key] = $key;
}
//	dd($unitAttributes);
$_aTitles = Entity::where("type", "jobconf")->where("format", $_format)->distinct("content.title")->get();
$_aTitles = array_flatten($_aTitles->toArray());
foreach ($_aTitles as $key => $value) {
    $pos = strpos($value, '[[');
    if ($pos > 0) {
        $t = trim(substr($value, 0, $pos));
        if (!array_key_exists($t, $aTitles)) {
            $aTitles[$t] = $t;
        }
    }
}
$_aTypes = Template::distinct('type')->get();
$_aTypes = array_flatten($_aTypes->toArray());
foreach ($_aTypes as $key => $value) {
    if (!isset($aTypes[$value])) {
        $aTypes[$value] = $value;
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:31,代码来源:submit.blade.php

示例12: updateReservation

 /**
  * Create a new reservation for a authenticated user.
  * @param $clustername : cluster's name from url.
  *
  */
 public function updateReservation(Cluster $cluster, $id)
 {
     if (!strcmp($cluster->clustername, Auth::user()->clustername) || Auth::user()->isAdmin()) {
         $content = Request::instance()->getContent();
         if (empty($content)) {
             return $this->_sendErrorMessage(400, "Payload.Null", "Received payload is empty.");
         }
         if (Input::json() == null) {
             return $this->_sendErrorMessage(400, "Payload.Invalid", "Received payload is invalid.");
         }
         $thing_uri = Input::json()->get('thing');
         $thing_name = explode('/', $thing_uri);
         $thing_name = $thing_name[count($thing_name) - 1];
         $thing_uri = str_replace($thing_name, '', $thing_uri);
         Input::json()->set('thing', $thing_uri);
         $reservation_validator = Validator::make(Input::json()->all(), array('thing' => 'required|url', 'type' => 'required', 'time' => 'required|time', 'subject' => 'required', 'announce' => 'required', 'customer' => 'required|customer'));
         if (!$reservation_validator->fails()) {
             $entity_name = explode('/', Input::json()->get('thing'));
             $entity_name = $entity_name[count($entity_name) - 1];
             $entity = Entity::where('name', '=', $entity_name)->where('type', '=', Input::json()->get('type'))->where('user_id', '=', $cluster->user->id)->first();
             if (!isset($entity)) {
                 return $this->_sendErrorMessage(404, "Thing.NotFound", "Thing not found.");
             } else {
                 $reservation = Reservation::find($id);
                 if ($reservation->exists) {
                     $time = Input::json()->get('time');
                     if ($this->isAvailable(json_decode($entity->body)->opening_hours, $time)) {
                         //timestamps are UTC so we convert dates to UTC timezone
                         $from = new DateTime($time['from']);
                         $to = new DateTime($time['to']);
                         $from->setTimezone(new DateTimeZone('UTC'));
                         $to->setTimezone(new DateTimeZone('UTC'));
                         $reservation = Reservation::activatedOrBlocking()->where('user_id', '=', $cluster->user->id)->where('entity_id', '=', $entity->id)->where('from', '<', $to)->where('to', '>', $from)->first();
                         if (!empty($reservation)) {
                             return $this->_sendErrorMessage(404, "Thing.AlreadyReserved", "The thing is already reserved at that time.");
                         } else {
                             $reservation->from = $from->getTimestamp();
                             $reservation->to = $to->getTimestamp();
                             $reservation->subject = Input::json()->get('subject');
                             $reservation->comment = Input::json()->get('comment');
                             $reservation->announce = json_encode(Input::json()->get('announce'));
                             $reservation->customer = json_encode(Input::json()->get('customer'));
                             $reservation->entity_id = $entity->id;
                             $reservation->user_id = $cluster->user->id;
                             return $reservation->save();
                         }
                     } else {
                         return $this->_sendErrorMessage(404, "Thing.Unavailable", "The thing is unavailable at that time.");
                     }
                 }
             }
         } else {
             return $this->_sendValidationErrorMessage($reservation_validator);
         }
     } else {
         return $this->_sendErrorMessage(403, "WriteAccessForbiden", "You can't make reservations on behalf of another user.");
     }
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:63,代码来源:ReservationController.php

示例13: fire

 /**
  * Execute the console command
  *
  * @return void
  */
 public function fire()
 {
     $allowed_types = array('array', 'boolean', 'integer', 'number', 'null', 'object', 'string');
     $user = User::where('username', '=', $this->option('user'))->first();
     if (!isset($user)) {
         $this->comment("This user don't exist.");
         return;
     }
     do {
         // get amenity's name
         do {
             $name = $this->ask("Amenity name : ");
             if (empty($name)) {
                 $this->comment("Your amenity name is empty.");
             }
         } while (empty($name));
         // check if an amenity with this name and user already exist
         $amenity = Entity::where('type', '=', 'amenity')->where('name', '=', $name)->first();
         if (isset($amenity)) {
             $this->comment("An amenity with this name already exists, please choose another one.");
         }
     } while (isset($amenity));
     // get amenity's title
     do {
         $title = $this->ask("Amenity title : ");
         if (empty($title)) {
             $this->comment("Your amenity title is empty.");
         }
     } while (empty($title));
     // get amenity's description
     do {
         $description = $this->ask("Amenity description : ");
         if (empty($description)) {
             $this->comment("Your amenity description is empty.");
         }
     } while (empty($description));
     $amenity = new Entity();
     $amenity->user_id = $user->id;
     $amenity->type = "amenity";
     $amenity->name = $name;
     $json_schema = array();
     $json_schema['$schema'] = "http://json-schema.org/draft-04/schema#";
     $json_schema['title'] = $title;
     $json_schema['description'] = $description;
     $json_schema['type'] = 'object';
     $json_schema['properties'] = array();
     $i = 0;
     $this->info("\n\n{$amenity->name} properties.");
     do {
         $this->comment("\n# Property {$i}");
         // get property name
         do {
             $name = $this->ask("\tProperty name : ");
             if (in_array($name, array_keys($json_schema['properties']))) {
                 $this->comment("A property with this name already exist.");
             }
             if (empty($name)) {
                 $this->comment("Your property name is empty.");
             }
         } while (in_array($name, array_keys($json_schema['properties'])) || empty($name));
         // get property description
         do {
             $description = $this->ask("\tProperty description : ");
             if (empty($description)) {
                 $this->comment("Your property description is empty.");
             }
         } while (empty($description));
         // set property name and description
         $json_schema['properties'][$name] = array();
         $json_schema['properties'][$name]['description'] = $description;
         // get property type and verify if it is a valid json-schema core type
         do {
             $type = $this->ask("\tProperty type (array, boolean, integer, number, null, object, string) : ");
             if (!in_array($type, $allowed_types)) {
                 $this->comment("The property type you provided is not valid. Valid types are 'array', 'boolean', 'integer', 'number', 'null', 'object', 'string'.");
             }
         } while (!in_array($type, $allowed_types));
         // set property type
         $json_schema['properties'][$name]['type'] = $type;
         $stop = $this->ask("\nDo you want to add another property ? [Y]/n") == "Y" ? 0 : 1;
         $i++;
     } while (!$stop);
     $amenity->body = json_encode($json_schema);
     $amenity->save();
     $this->info("Amenity '{$amenity->name}' has been saved.");
     return;
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:92,代码来源:AddAmenity.php

示例14: getUnitsrelex

 public function getUnitsrelex()
 {
     $count = 0;
     foreach (\Workerunit::where('type', 'RelEx')->get() as $ann) {
         set_time_limit(30);
         if (!isset($ann->content)) {
             echo "{$ann->_id} no content\r\n";
             echo "--------------------------------\r\n";
             continue;
         }
         if (!empty($ann->unit_id)) {
             echo "{$ann->_id} has unitid\r\n";
             continue;
         }
         //dd($ann->question);
         //$xml = simplexml_load_string($ann->question);
         //$url = (string) $xml->ExternalURL;
         $xml = simplexml_load_string($ann->question);
         //$html = $ann->question;//
         $html = (string) $xml->HTMLContent;
         //dd($html);
         $dom = HtmlDomParser::str_get_html($html);
         $sentence = rtrim($dom->find('span[class=senval]', 0)->innertext, '.');
         $term1 = $dom->find('span[style=color:#0000CD;]', 1)->innertext;
         $term2 = $dom->find('span[style=color:#0000CD;]', 2)->innertext;
         /*			$sentence = "Poisson regression analysis which included data for multiple measurements of Tme/[TE] over the first year of life and adjusted for age-at-test and maternal smoking during [PREGNANCY] also demonstrated a greater decrease in Tme/Te in female infants who subsequently develop an LRI (P = 0.08";
         			$term1 = "[PREGNANCY]";
         			$term2 = "[TE]";*/
         $unit = Entity::where('content.terms.first.formatted', $term1)->where('content.terms.second.formatted', $term2)->where('content.sentence.formatted', $sentence)->first();
         /*			if(!$unit){
         				$hi = 0;
         				$units = Entity::where('content.terms.first.formatted', $term1)
         						->where('content.terms.second.formatted', $term2)
         						->get();
         
         				foreach($units as $punit){
         					try{
         						$pct = similar_text($sentence, $punit->content['sentence']['formatted']);
         					} catch (ErrorException $e) {
         						echo "\r\n\r\n\r\n\r\n{$punit->_id}\r\n\r\n\r\n\r\n";
         						$pct = similar_text(strtolower($sentence), strtolower($punit->content['sentence']['text']));
         					}	
         					if($pct>$hi) {
         						$hi=$pct;
         						$unit = $punit;
         					}
         				}
         
         			} */
         if ($unit) {
             echo "\r\n\\YY {$sentence}\r\n";
             echo "== " . $unit->content['sentence']['formatted'];
             echo "\r\n{$ann->_id}->{$unit->_id}\r\n";
             $ann->unit_id = $unit->_id;
             $ann->save();
         } else {
             echo "\r\nNO {$ann->_id}\r\n{$term1}--{$term2}--{$sentence}\r\n";
             //echo $punit->content['sentence']['formatted'];
             //echo "\r\n{$ann->unit_id}----------------\r\n";
             echo "----------------------------------------";
             continue;
         }
     }
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:64,代码来源:tempImportAndVectorsMethodsController.php

示例15: deleteAmenity

 /**
  * Delete an amenity.
  * @param $clustername : cluster's name from the url
  * @param $name : the name of the amenity to be deleted
  *
  */
 public function deleteAmenity(Cluster $cluster, $name)
 {
     if (!strcmp($cluster->clustername, Auth::user()->clustername) || Auth::user()->isAdmin()) {
         $amenity = Entity::where('user_id', '=', $cluster->user->id)->where('type', '=', 'amenity')->where('name', '=', $name);
         if ($amenity->first() != null) {
             if ($amenity->delete()) {
                 return Response::json(array('success' => true, 'message' => 'Amenity successfully deleted'));
             } else {
                 return $this->_sendErrorMessage(500, "Amenity.Unknown", "An error occured while deleting the amenity.");
             }
         } else {
             return $this->_sendErrorMessage(404, "Amenity.NotFound", "Amenity not found.");
         }
     } else {
         return $this->_sendErrorMessage(403, "DeleteAccessForbiden", "You can't delete amenities from another user.");
     }
 }
开发者ID:tallcoder,项目名称:Reservations,代码行数:23,代码来源:EntityController.php


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