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


PHP Statement::where方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $lrs_collection = (new Lrs())->get();
     // Remove all inactive statements.
     Statement::where('active', '=', false)->delete();
     // Migrates the statements for each LRS.
     foreach ($lrs_collection as $lrs) {
         Statement::where('lrs._id', $lrs->_id)->chunk(500, function ($statements) use($lrs) {
             $statements_array = [];
             // Sets `active` and `voided` properties.
             // Ensures that statement is an associative array.
             $statements = $statements->each(function ($statement) {
                 $statement->voided = isset($statement->voided) ? $statement->voided : false;
                 $statement->active = isset($statement->active) ? $statement->active : true;
                 $statement->save();
                 $statements_array[] = (array) json_decode($statement->toJSON());
             });
             // Uses the repository to migrate the statements.
             $repo = App::make('Locker\\Repository\\Statement\\EloquentVoider');
             $repo->updateReferences($statements_array, $lrs);
             $repo->voidStatements($statements_array, $lrs);
             // Outputs status.
             $statement_count = $statements->count();
             $this->info("Migrated {$statement_count} statements in `{$lrs->title}`.");
         });
     }
     $this->info('All statements migrated.');
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:33,代码来源:StatementMigrateCommand.php

示例2: courses

 public function courses()
 {
     $courses = array();
     $return_results = array();
     foreach ($this->data as $d) {
         if (isset($d['context']['contextActivities'])) {
             foreach ($d['context']['contextActivities']['grouping'] as $key => $value) {
                 if ($key === 'type' && $value == 'http://adlnet.gov/expapi/activities/course') {
                     $courses[] = $d['context']['contextActivities']['grouping']['id'];
                 }
             }
         }
     }
     $array = array_count_values($courses);
     arsort($array);
     $results = array_slice($array, 0, 4);
     foreach ($results as $key => $value) {
         $get_name = \Statement::where('context.contextActivities.grouping.id', $key)->first();
         if (isset($get_name['context']['contextActivities']['grouping']['definition']['name']['en-gb'])) {
             $return_results[] = array('name' => $get_name['context']['contextActivities']['grouping']['definition']['name']['en-gb'], 'count' => $value);
         } else {
             $return_results[] = array('name' => $get_name['context']['contextActivities']['grouping']['definition']['name']['en-GB'], 'count' => $value);
         }
     }
     $this->results = $return_results;
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:26,代码来源:Filter.php

示例3: convertStatements

 public function convertStatements($lrs)
 {
     $statements = OldStatement::where('context.extensions.http://learninglocker&46;net/extensions/lrs._id', $lrs)->get();
     $new_statements = array();
     //new stdClass();
     $this->loopStatements($statements);
     $count = Statement::where('lrs._id', $lrs)->count();
     return Response::json(array('success' => true, 'count' => $count));
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:9,代码来源:MigrateController.php

示例4: selectStatementDocs

 /**
  * Gets statement documents based on a filter.
  * 
  * @param $lrs       id      The Lrs to search in (required)
  * @param $filter    array   The filter array
  * @param $raw       boolean  Pagination or raw statements?
  * @param $sections  array   Sections of the statement to return, default = all
  * 
  * @return Statement query
  */
 public function selectStatementDocs($lrs = '', $filter, $raw = false, $sections = [])
 {
     //var_dump( $filter );exit;
     $statements = \Statement::where('lrs._id', $lrs);
     if (!empty($filter)) {
         foreach ($filter as $key => $value) {
             if (is_array($value)) {
                 //does the array contain between values? e.g. <> 3, 6
                 if ($value[0] === '<>') {
                     $statements->whereBetween($key, array((int) $value[1], (int) $value[2]));
                 } else {
                     $statements->whereIn($key, $value);
                     //where key is in array
                 }
             } else {
                 $statements->where($key, $value);
             }
         }
     }
     return $statements;
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:31,代码来源:EloquentQueryRepository.php

示例5: checkStatement

 private function checkStatement($id, $expected_references = [], $expected_referrers = [])
 {
     $uuid = $this->generateUUID($id);
     $statement = \Statement::where('lrs_id', new \MongoId($this->lrs->_id))->where('statement.id', '=', $uuid)->first();
     //$queries = DB::getQueryLog();
     $expected_references = array_map(function ($ref) {
         return $this->generateUUID($ref);
     }, $expected_references);
     $expected_referrers = array_map(function ($ref) {
         return $this->generateUUID($ref);
     }, $expected_referrers);
     // Checks $expected_references.
     $references = array_map(function ($ref) {
         return $ref['id'];
     }, isset($statement->refs) ? $statement->refs : []);
     // Checks $expected_referrers.
     $referrers = (new \Statement())->select('statement.id')->where('statement.object.id', '=', $uuid)->where('statement.object.objectType', '=', 'StatementRef')->get()->toArray();
     $referrers = array_map(function ($ref) {
         return $ref['statement']['id'];
     }, $referrers);
     $diff = array_diff($expected_referrers, $referrers);
     $this->assertEquals(true, empty($diff) || count($diff) === 0, json_encode($diff) . json_encode($expected_referrers) . json_encode($referrers));
 }
开发者ID:scmc,项目名称:learninglocker,代码行数:23,代码来源:StatementRefTest.php

示例6: destroy

 /**
  * Destroys the model with the given ID and options.
  * @param String $lrs_id ID to match.
  * @param [String => Mixed] $opts
  * @return Boolean
  */
 public function destroy($lrs_id, array $opts)
 {
     // Delete related documents from client and oauth_clients collections.
     $clients = ClientModel::where('lrs_id', $lrs_id)->get();
     foreach ($clients as $client) {
         $client->delete();
     }
     StatementModel::where('lrs_id', $lrs_id)->delete();
     return parent::destroy($lrs_id, $opts);
 }
开发者ID:learninglocker,项目名称:learninglocker,代码行数:16,代码来源:EloquentRepository.php

示例7: destroy

 /**
  * Destroys the model with the given ID and options.
  * @param String $id ID to match.
  * @param [String => Mixed] $opts
  * @return Boolean
  */
 public function destroy($id, array $opts)
 {
     StatementModel::where('lrs._id', $id)->delete();
     return parent::destroy($id, $opts);
 }
开发者ID:hsz-develop,项目名称:LearningLocker--learninglocker,代码行数:11,代码来源:EloquentRepository.php

示例8: URL

  <ul>
    <li>First you need to rename the mongodb collection statements => old_statements. 
      You can do this by opening a terminal, get the mongo shell running and using the following command:<br />
      <div class="well">
        db.statements.renameCollection('old_statements')
      </div><br />
      Once done, refresh this page and move on to the next step.
    </li>
    <li>Next, click on the migrate button under each LRS listed below to migrate the statements.</li>
  </ul> 
  <div id="loading" style="margin:10px 0 10px 0;display:none;"><img src="{{ URL() }}/assets/img/ajax-loader.gif" /></div>
  <ul class="list-group col-sm-8">
  @foreach($lrs as $l)
    <?php 
$count = OldStatement::where('context.extensions.http://learninglocker&46;net/extensions/lrs._id', $l->_id)->count();
$count_new = Statement::where('lrs._id', $l->_id)->count();
?>
    @if( $count > 0 )
    <li class="list-group-item">
      <span class="badge">{{ $count }}</span>
      <p>{{ $l->title }}</p>
      @if( isset($count_new) && $count_new != 0 )
        <div class="label label-success">{{ $count_new }}</div>
      @endif 
      <div class="label label-success new_count" style="font-size:16px;padding:8px;"></div>
      @if( !isset($count_new) || $count_new == 0 ) 
        <div class="migrate btn btn-primary btn-sm" data-lrs="{{$l->_id}}"><i class="icon-play-circle"></i> Migrate</div>
      @endif
    </li>
    @endif
  @endforeach
开发者ID:scmc,项目名称:learninglocker,代码行数:31,代码来源:index.blade.php

示例9: getVerbs

 public function getVerbs($lrs)
 {
     $verbs = \Statement::where('lrs._id', $lrs)->select('statement.verb')->distinct()->remember(15)->get()->toArray();
     return $verbs;
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:5,代码来源:getVerbs.php

示例10: setSelect

 private function setSelect($lrs, $select)
 {
     return \Statement::where('lrs._id', $lrs)->select($select)->distinct()->remember(15)->get();
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:4,代码来源:getContext.php

示例11: getActivities

 public function getActivities($lrs)
 {
     return \Statement::where('lrs._id', $lrs)->where('statement.object.objectType', 'Activity')->select('statement.object.definition.type')->distinct()->remember(15)->get()->toArray();
     return array('activities' => $activities, 'types' => $activity_types);
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:5,代码来源:getActivities.php

示例12: relatedActivities

 /**
  * Related Activities
  *
  **/
 private function relatedActivities($statements, $lrs, $activityId)
 {
     $ids = array();
     foreach ($statements as $s) {
         $ids[] = $s->id;
     }
     //look in context parent
     $parent = \Statement::where('lrs._id', $lrs)->where('statement.context.contextActivities.parent.objectType', 'Activity')->where('statement.context.contextActivities.parent.id', $activityId)->get();
     if ($parent) {
         $statements = $this->addStatements($statements, $parent, $ids);
     }
     //look in context grouping
     $grouping = \Statement::where('lrs._id', $lrs)->where('statement.context.contextActivities.grouping.objectType', 'Activity')->where('statement.context.contextActivities.grouping.id', $activityId)->get();
     if ($grouping) {
         $statements = $this->addStatements($statements, $grouping, $ids);
     }
     //look in context category
     $category = \Statement::where('lrs._id', $lrs)->where('statement.context.contextActivities.category.objectType', 'Activity')->where('statement.context.contextActivities.category.id', $activityId)->get();
     if ($category) {
         $statements = $this->addStatements($statements, $category, $ids);
     }
     //look in context other
     $other = \Statement::where('lrs._id', $lrs)->where('statement.context.contextActivities.other.objectType', 'Activity')->where('statement.context.contextActivities.other.id', $activityId)->get();
     if ($category) {
         $statements = $this->addStatements($statements, $other, $ids);
     }
     return $statements;
 }
开发者ID:jesposito,项目名称:learninglocker,代码行数:32,代码来源:EloquentStatementRepository.php


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