Illuminate\Support\Collection::contains PHP Method

contains() public method

Determine if an item exists in the collection.
public contains ( mixed $key, mixed $value = null ) : boolean
$key mixed
$value mixed
return boolean
    public function contains($key, $value = null)
    {
        if (func_num_args() == 2) {
            return $this->contains(function ($item) use($key, $value) {
                return data_get($item, $key) == $value;
            });
        }
        if ($this->useAsCallable($key)) {
            return !is_null($this->first($key));
        }
        return in_array($key, $this->items);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @return $this
  */
 public function withImages()
 {
     if (!$this->extended->contains("images")) {
         return $this->extend('images');
     }
     return $this;
 }
All Usage Examples Of Illuminate\Support\Collection::contains