offsetSet() public method

Set the item at a given offset.
public offsetSet ( mixed $key, mixed $value ) : void
$key mixed
$value mixed
return void
Example #1
0
 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;
 }
Example #2
0
 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));
     }
 }
Example #3
0
 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]);
 }
Example #4
0
 /**
  * @param IJobHandler $handler
  */
 public function pushHandler(IJobHandler $handler)
 {
     $this->handlers->offsetSet($handler->getType(), $handler);
 }
Example #5
0
 /**
  * @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;
 }
Example #6
0
 /**
  * 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;
 }
Example #7
0
 /**
  * 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;
 }
Example #8
0
 /**
  *
  */
 protected function addFieldData($fieldName, $value)
 {
     $this->data->offsetSet($fieldName, $value);
 }
Example #9
0
 /**
  * @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;
 }
 /**
  * @param  mixed            $key
  * @param  ServiceInterface $value
  * @return void
  */
 public function offsetSet($key, $value)
 {
     $this->checkValidService($value);
     parent::offsetSet($key, $value);
 }
Example #11
0
 public function offsetSet($key, $value)
 {
     parent::offsetSet(strtoupper($key), $value);
 }