Illuminate\Support\Collection::forget PHP Method

forget() public method

Remove an item from the collection by key.
public forget ( string | array $keys )
$keys string | array
    public function forget($keys)
    {
        foreach ((array) $keys as $key) {
            $this->offsetUnset($key);
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * @param WithInterface|DataInterface|ModelInterface $config
  * @return mixed
  */
 public function apply($config)
 {
     if (!($config instanceof WithInterface && $config instanceof DataInterface && $config instanceof ModelInterface)) {
         return;
     }
     if ($config->with()->isEmpty()) {
         return;
     }
     $this->config = $config;
     $this->allowed = $config->with();
     foreach ($this->allowed as $key => $value) {
         if (is_numeric($key)) {
             $this->allowed->forget($key)->put($value, '*');
         }
     }
     foreach (explode('|', $config->data()->get('with', '')) as $with) {
         $parts = explode(':', $with);
         if (count($parts) == 0) {
             continue;
         }
         if (!$this->allowed->has($parts[0])) {
             continue;
         }
         $this->processWith($parts[0], isset($parts[1]) ? $parts[1] : '');
     }
     if (count($this->approved) > 0) {
         $config->model($config->model()->with($this->approved));
     }
 }
All Usage Examples Of Illuminate\Support\Collection::forget