Illuminate\Support\Collection::except PHP Method

except() public method

Get all items except for those with the specified keys.
public except ( mixed $keys ) : static
$keys mixed
return static
    public function except($keys)
    {
        $keys = is_array($keys) ? $keys : func_get_args();
        return new static(Arr::except($this->items, $keys));
    }

Usage Example

Exemplo n.º 1
0
 public function testExcept()
 {
     $data = new Collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => '*****@*****.**']);
     $this->assertEquals(['first' => 'Taylor'], $data->except(['last', 'email', 'missing'])->all());
     $this->assertEquals(['first' => 'Taylor'], $data->except('last', 'email', 'missing')->all());
     $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->except(['last'])->all());
     $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->except('last')->all());
 }