本文整理汇总了PHP中Illuminate\Support\Collection::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::__construct方法的具体用法?PHP Collection::__construct怎么用?PHP Collection::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(string $name, array $options = [])
{
parent::__construct();
$this->name = $name;
$this->caption = $options['caption'] ?? $name;
$this->priority = $options['priority'] ?? $this->priority;
}
示例2: __construct
public function __construct($items = [])
{
$this->storagePath = storage_path('logs');
$this->filesystem = new Filesystem(app('files'), $this->storagePath);
parent::__construct($items);
$this->load();
}
示例3: __construct
/**
* Construct a collection of Result objects based on the hits
* in the Elasticsearch response
*
* @param Response $response
*/
public function __construct(Response $response)
{
$this->response = $response;
parent::__construct(array_map(function ($hit) {
return new Result($hit);
}, $this->response->getHits()));
}
示例4: __construct
public function __construct(array $entities = null)
{
if ($entities) {
$this->checkItemsAreMappable($entities);
}
parent::__construct($entities);
}
示例5: __construct
public function __construct($items = null)
{
if (is_null($items)) {
return parent::__construct(config('amazon.mws'));
}
return parent::__construct($items);
}
示例6: __construct
/**
* @inheritdoc
*/
public function __construct($items = null, $class_slug = null, $key_by = null)
{
$items = is_null($items) ? [] : $items;
if ($items instanceof \Illuminate\Support\Collection) {
return parent::__construct($items);
}
if ($class_slug) {
$items = array_map(function ($item) use($class_slug) {
if (is_null($item)) {
return $item;
}
if (!is_array($item)) {
throw new \Exception("Failed to cast a model");
}
$class = Model::getModelClass($class_slug);
return new $class($item);
}, $items);
}
if ($key_by) {
$items = array_build($items, function ($key, $value) use($key_by) {
/** @var Model $value */
$key = $value instanceof Model ? $value->get($key_by) : data_get($value, $key_by);
return [$key, $value];
});
}
return parent::__construct($items);
}
示例7: __construct
/**
* Create a new article collection instance.
*
* @param \JasonLewis\Website\Loader $loader
* @param \Illuminate\Cache\CacheManager $cache
* @param int $expires
* @param array $items
* @return void
*/
public function __construct(Loader $loader, CacheManager $cache, $expires, $items = [])
{
$this->loader = $loader;
$this->cache = $cache;
$this->expires = $expires;
parent::__construct($items);
}
示例8: __construct
public function __construct(array $messages = [])
{
$messageModels = [];
foreach ($messages as $message) {
$messageModels[] = new Model($message);
}
parent::__construct($messageModels);
}
示例9: __construct
public function __construct($opt = [])
{
$opt = $this->convertOptions($opt);
$options = $opt;
$options['chart'] = new ChartPropertie(isset($options['chart']) ? $options['chart'] : []);
parent::__construct($options);
$this->resolveID($opt);
}
示例10: __construct
/**
* @param array $params
*/
public function __construct(array $params = array())
{
foreach ($params['profiles'] as &$profile) {
$profile = new Subscription($profile);
}
parent::__construct($params['profiles']);
unset($params);
}
示例11: __construct
/**
* @param ServiceInterface[] $items
*/
public function __construct($items = [])
{
$items = is_array($items) ? $items : $this->getArrayableItems($items);
foreach ($items as $index => $item) {
$this->checkValidService($item);
}
parent::__construct($items);
}
示例12: __construct
public function __construct(array $params = array())
{
$this->updatedAt = Carbon::createFromTimestamp($params['updatetime'], $params['timezone']);
foreach ($params['measuregrps'] as &$group) {
$group = new Measure($group);
}
parent::__construct($params['measuregrps']);
unset($params);
}
示例13: __construct
/**
* Create a new ContentItem.
*
*
* @param array $items
*
* @throws MissingParameterContentItemException
*/
public function __construct($items = [])
{
//New Up parent
parent::__construct($items);
//If we do not have content then throw an Exception
if (!$this->has('content')) {
throw new MissingParameterContentItemException('Personality Insights requires a content', 422);
}
}
示例14: __construct
/**
* Construct a collection of Eloquent models based on the search result
*
* @access public
* @param Response $response
*/
public function __construct(Response $response)
{
$this->response = $response;
$ids = array_map(function ($hit) {
return $hit['_id'];
}, $this->response->getHits());
$model = $response->getModel();
parent::__construct($model::whereIn('id', $ids)->get()->toArray());
}
示例15: __construct
public function __construct($creds)
{
$this->connection = new PexConnection($creds);
$accountlist = $this->connection->allAccounts();
$items = array();
foreach ($accountlist as $act) {
$items[] = new Account($this->connection, $act);
}
parent::__construct($items);
}