Laravel - Collections - Method Forget
The forget
method removes an item from the collection by its key:
$collection = collect(['name' => 'taylor', 'framework' => 'laravel']);
$collection->forget('name');
$collection->all();
// ['framework' => 'laravel']
Unlike most other collection methods, forget
does not return a new modified collection; it modifies the collection it is called on.