本文整理匯總了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);
}