本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::whereIn方法的具体用法?PHP Model::whereIn怎么用?PHP Model::whereIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::whereIn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findWhereIn
/**
* Find data by multiple values in one field
*
* @param $field
* @param array $values
* @param array $columns
*
* @return mixed
*/
public function findWhereIn($field, array $values, $columns = ['*'])
{
$this->applyCriteria();
$model = $this->model->whereIn($field, $values)->get($columns);
$this->resetModel();
return $this->parserResult($model);
}
示例2: whereIn
/**
* Find data by multiple values in one field
*
* @param $field
* @param array $values
*
* @return mixed
*/
public function whereIn($field, array $values)
{
$this->applyCriteria();
$this->model = $this->model->whereIn($field, $values);
return $this;
//return $this->parserResult($model);
}
示例3: whereIn
/**
* Add whereIn condition for next query.
*
* @param string $column
* @param array $value
*
* @return void
*/
public function whereIn($column, array $value)
{
$this->model = $this->model->whereIn($column, $value);
return $this;
}
示例4: whereIn
/**
* @param string $field
* @param array $whereIn
* @return mixed
*/
public function whereIn($field, $whereIn = array())
{
return $this->model->whereIn($field, $whereIn)->get();
}
示例5: map
/**
* Map the given results to instances of the given model.
*
* @param mixed $results
* @param \Illuminate\Database\Eloquent\Model $model
* @return Collection
*/
public function map($results, $model)
{
if (count($results['hits']['total']) === 0) {
return Collection::make();
}
$keys = collect($results['hits']['hits'])->pluck('_id')->values()->all();
$models = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
return collect($results['hits']['hits'])->map(function ($hit) use($model, $models) {
return $models[$hit['_id']];
});
}
示例6: byIds
/**
* Get multi model by ids
*
* @param string slug
* @return object object of model
*/
public function byIds($ids)
{
return $this->model->whereIn('_id', $ids)->get();
}
示例7: whereIn
/**
* Get list record from list data
* @param $field
* @param array $data
* @return mixed
*/
public function whereIn($field, $data = array())
{
return $this->model->whereIn($field, $data);
}
示例8: scopeWhereInSubQuery
/**
* @param EloquentBuilder|QueryBuilder|Model $query
* @param string $column
* @param EloquentBuilder|QueryBuilder|Model $subQuery
* @param string $subQueryColumn
*
* @return QueryBuilder
*/
public function scopeWhereInSubQuery($query, $column, $subQuery, $subQueryColumn)
{
if (!Str::contains($column, '.')) {
/** @var Model|BetterEloquentTrait $model */
$model = $query->getModel();
$column = $model->getField($column);
}
$subQuery = $subQuery->toSubQuery($subQueryColumn, true);
return $query->whereIn($column, $subQuery);
}