To flip the keys with the values in a Laravel collection, you can use the flip
method. This method will create a new collection with the keys and values swapped.
Here’s an example:
$collection = collect(['name' => 'bob', 'job' => 'developer']);
$flipped = $collection->flip();
// $flipped = ['bob' => 'name', 'developer' => 'job']