Laravel ::pluck multiple columns
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Laravel Eloquent: How to Pluck Multiple Columns for Blade Select Tags
As developers working with Laravel and Eloquent, one of the most common tasks is populating dynamic form elements, especially <select> tags. When you need to populate a dropdown list, you typically want to use the primary key (id) as the value, but display some combination of other data (like a concatenated string) to the end-user.
This post addresses a specific pattern: how to use the pluck() method when dealing with multiple columns, and what to do when you need custom logic, such as concatenating fields before selecting an ID.
The Limitation of pluck() for Custom Logic
You asked about the syntax: Model::pluck('column_1 & column_2', 'id'). While this expression looks very intuitive, it will not work as expected in Eloquent's standard pluck() method.
The fundamental purpose of pluck($column) is to retrieve an array containing only the values from that single specified column across all model instances (e.g., [1, 2, 3]). It is designed for simple retrieval, not complex relational operations or string concatenation during the selection process. Trying to pass a concatenated string as the first argument usually results in an error or unexpected behavior because Eloquent expects a single column name.
If your goal is simply to get a list of IDs based on some criteria, pluck() is perfect. However, if you need to construct a custom display value for the dropdown and retrieve the ID simultaneously, we need a more robust approach.
Best Alternative 1: Using select() and pluck() Together (The Efficient Route)
For maximum performance and adherence to Eloquent principles, the best practice is to explicitly select only the columns you need before plucking the results. This minimizes the data retrieved from the database.
If you only need the IDs for the dropdown options, simply pluck the ID column:
// Assuming you want a list of IDs for the select tag values
$ids = YourModel::where('status', 'active')->pluck('id');
// Use $ids to populate your blade select tag
echo '<select name="item_id">';
foreach ($ids as $id) {
echo '<option value="' . $id . '">' . $id . '</option>';
}
echo '</select>';This method is fast and clean, especially when dealing with large datasets. For general Eloquent query building, understanding how to scope your queries efficiently is key, as promoted by best practices found on the official Laravel documentation at laravelcompany.com.
Best Alternative 2: Using select() and Collection Mapping (The Flexible Route)
When you need to concatenate columns (column_1 and column_2) to create a unique display string for the dropdown, you must fetch the full data set first and then perform the concatenation in PHP using a Collection. This gives you total control over the output format.
This approach is more verbose but handles complex formatting flawlessly:
// Fetch the necessary columns from the database
$items = YourModel::where('status', 'active')->select('id', 'column_1', 'column_2')->get();
// Map the results to create the custom string for the select tag
$options = $items->map(function ($item) {
// Concatenate column_1 and column_2, separated by a delimiter
$displayValue = $item->column_1 . ' - ' . $item->column_2;
// Return an array suitable for the select tag (value => text)
return [
'value' => $item->id,
'text' => $displayValue,
];
});
// Now iterate over the mapped results to build the blade HTML
echo '<select name="items">';
foreach ($options as $option) {
// The option value is the ID, the displayed text is the concatenation
echo '<option value="' . $option['value'] . '">' . $