本文整理汇总了PHP中Illuminate\Database\Eloquent\Collection::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::__construct方法的具体用法?PHP Collection::__construct怎么用?PHP Collection::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Collection
的用法示例。
在下文中一共展示了Collection::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* MetaItemCollection constructor.
*
* @param array $items
*/
public function __construct($items = [])
{
parent::__construct($items);
$this->original_model_keys = $this->modelKeys();
$this->setTags($this->items);
$this->observeDeletions($this->items);
}
示例2: __construct
public function __construct($items)
{
parent::__construct($items);
foreach ($items as $role) {
$this->roles[$role->id] = $role->name;
$this->permissions = array_merge($this->permissions, $role->getPermissionsArray());
}
}
示例3: __construct
public function __construct($items = [])
{
$posts = [];
foreach ($items as $item) {
$posts[] = Post::resolveWordPressPostToModel($item);
}
parent::__construct($posts);
}
示例4: __construct
/**
* Constructor.
* @param array $items
*/
public function __construct($items = [])
{
parent::__construct($items);
foreach ($this->items as $input) {
if (!$this->class) {
$this->class = $input->object;
}
$this->fields[$input->name] = $input;
}
}
示例5: __construct
public function __construct($models)
{
if ($models instanceof UploadCollection) {
$medias = $this;
$models->each(function ($upload) use($medias) {
$medias->push($upload);
});
} else {
parent::__construct($models);
}
}
示例6: __construct
/**
* Create a new instance containing Elasticsearch results
*
* @todo Remove backwards compatible detection at further point
* @deprecated Initialize with params ($results, $instance) is deprecated,
* please use Model::hydrateElasticsearchResult($results).
*
* @param mixed $items
* @param array $meta
* @return void
*/
public function __construct($items, $meta = null)
{
// Detect if arguments are old deprecated version ($results, $instance)
if (isset($items['hits']) and $meta instanceof \Illuminate\Database\Eloquent\Model) {
$instance = $meta;
$meta = $items;
$items = $instance::hydrateElasticsearchResult($meta);
}
parent::__construct($items);
// Take our result meta and map it
// to some class properties.
if (is_array($meta)) {
$this->setMeta($meta);
}
}
示例7: foreach
/**
* Convert all file types to url paths
*/
function __construct($models)
{
foreach ($models as $model) {
if (isset($model->files)) {
foreach ($model->files as $file) {
$method = camel_case($file);
try {
$model[$file] = $model->{$method}();
} catch (\BadMethodCallException $e) {
$model[$file] = $model::Uploader()->get($model[$file]);
}
}
}
}
return parent::__construct($models);
}
示例8: __construct
public function __construct(array $items = array(), $parentKey = 'parent_id')
{
parent::__construct($items);
$this->total = count($items);
$this->parentKey = $parentKey;
}
示例9: __construct
public function __construct($items = [])
{
parent::__construct($items);
$this->parentColumn = 'parent_id';
$this->total = count($items);
}
示例10: __construct
public function __construct(array $items = array())
{
parent::__construct($items);
$this->total = count($items);
}
示例11: __construct
/**
* Create a new collection.
*
* @param mixed $items
* @param string|null $className
*/
public function __construct($items = [], $className = null)
{
parent::__construct($items);
$this->className = $className;
}
示例12: __construct
/**
* Constructor.
* @param array $items
*/
public function __construct($items = [])
{
parent::__construct($items);
}
示例13: __construct
/**
* Constructor.
* @param array $items
*/
public function __construct($items = [])
{
parent::__construct($items);
$this->index();
}
示例14: __construct
/**
* Constructor.
* @param array $items
*/
public function __construct($items = [])
{
parent::__construct($items);
array_map([$this, 'add'], $items);
}
示例15: __construct
/**
* @param array $models
*/
public function __construct($models)
{
parent::__construct($models);
}