包含模型到阵列的Laravel集合

I have a Laravel Collection containing several User models.

Collection([
    User,
    User,
])

The model contains for example username, first name, last name, email, date of birth. I only need username, email, date and have it in an array like this.

array(
    array('jonhdoe', 'johndoe@example.com', '1-1-1970')
)

so that I can access it with

$username = $array[0][0]
$email = $array[0][1]

and not

$username = $array[0]['username']
$email = $array[0]['email']

I was looking at the Laravel helpers each or map, but somehow I can't get it to work.

only() will return an array of specified columns only. And toArray() will transform the collection to array:

$collection->map(function($i) {
    return array_values($i->only('username', 'email', 'date'));
})->toArray();

Use toArray()-

$collection_in_arrays = $collection->toArray();

The toArray method converts the collection into a plain PHP array. If the collection's values are Eloquent models, the models will also be converted to arrays.