Illuminate\Support\Collection::pull PHP Method

pull() public method

Get and remove an item from the collection.
public pull ( mixed $key, mixed $default = null ) : mixed
$key mixed
$default mixed
return mixed
    public function pull($key, $default = null)
    {
        return Arr::pull($this->items, $key, $default);
    }

Usage Example

 /**
  * Process the payload.
  * @param Collection $payload
  * @return Collection
  */
 public function process($payload)
 {
     $series = $payload->pull('series');
     $series->persist();
     if ($payload->has('game')) {
         $game = $payload->get('game');
         $series->relatesToGame($game);
     }
     $payload->put('series', $series->model);
     return $payload;
 }
All Usage Examples Of Illuminate\Support\Collection::pull