本文整理汇总了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.');
}
示例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;
}
示例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));
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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
示例9: getVerbs
public function getVerbs($lrs)
{
$verbs = \Statement::where('lrs._id', $lrs)->select('statement.verb')->distinct()->remember(15)->get()->toArray();
return $verbs;
}
示例10: setSelect
private function setSelect($lrs, $select)
{
return \Statement::where('lrs._id', $lrs)->select($select)->distinct()->remember(15)->get();
}
示例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);
}
示例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;
}