本文整理汇总了PHP中Illuminate\Support\Collection::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::offsetSet方法的具体用法?PHP Collection::offsetSet怎么用?PHP Collection::offsetSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::offsetSet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFiels
public function getFiels()
{
$values = new Collection();
foreach ($this->seoModel->getFillable() as $fill) {
if (!in_array($fill, ['document_id', 'document_type'])) {
$values->offsetSet($fill, null);
}
}
return $values;
}
示例2: offsetSet
public function offsetSet($key, $value)
{
$keySegments = explode('.', $key);
$firstKeySegment = array_shift($keySegments);
if ($keySegments) {
if (!$this->offsetExists($firstKeySegment)) {
$this->put($firstKeySegment, []);
}
$this->offsetGet($firstKeySegment)->items()->offsetSet(implode('.', $keySegments), $value);
} else {
parent::offsetSet($key, $this->validateItem($value));
}
}
示例3: testArrayAccessOffsetSet
public function testArrayAccessOffsetSet()
{
$c = new Collection(['foo', 'foo']);
$c->offsetSet(1, 'bar');
$this->assertEquals('bar', $c[1]);
$c->offsetSet(null, 'qux');
$this->assertEquals('qux', $c[2]);
}
示例4: pushHandler
/**
* @param IJobHandler $handler
*/
public function pushHandler(IJobHandler $handler)
{
$this->handlers->offsetSet($handler->getType(), $handler);
}
示例5: initCachedSettings
/**
* @return \Illuminate\Support\Collection
*/
private function initCachedSettings()
{
$settings = new Collection();
// Defaults settings
foreach ($this->defaults as $k => $v) {
if (isset($v['value'])) {
$settings->offsetSet($k, $v['value']);
}
}
// Database settings
foreach (Setting::all() as $s) {
$settings->offsetSet($s->identifier, $s->value);
}
$this->setCachedSettings($settings);
return $settings;
}
示例6: set
/**
* Set a specific key & value.
*
* @param string $key
* @param mixed $value
*
* @return $this
*/
public function set($key, $value)
{
$this->attributes->offsetSet($key, $value);
return $this;
}
示例7: addEntry
/**
* Add a new Entry to the collection.
*
* @param Entry $entry
*
* @return \Subbly\Presenter\Entries
*/
public function addEntry(Entry $entry)
{
$this->entries->offsetSet(null, $entry);
return $this;
}
示例8: addFieldData
/**
*
*/
protected function addFieldData($fieldName, $value)
{
$this->data->offsetSet($fieldName, $value);
}
示例9: initCachedStats
/**
* @return \Illuminate\Support\Collection
*/
private function initCachedStats()
{
$stats = new Collection();
// Defaults stats
foreach ($this->defaults as $k => $v) {
$stats->offsetSet($k, $v['value']);
}
// Database stats
foreach (Stats::all() as $s) {
$stats->offsetSet($s->service, $s);
}
$this->setCachedStats($stats);
return $stats;
}
示例10: offsetSet
/**
* @param mixed $key
* @param ServiceInterface $value
* @return void
*/
public function offsetSet($key, $value)
{
$this->checkValidService($value);
parent::offsetSet($key, $value);
}
示例11: offsetSet
public function offsetSet($key, $value)
{
parent::offsetSet(strtoupper($key), $value);
}