I'm struggling to see why my select list is returning an error.
I have a nested foreach loop, the second loop which should display records by building_id. However it is this very id which it returns an undefined variable for ($building->id)
Is it the construction of the query which is at fault?
<select>
@foreach (Building::orderBy('title')->get() as $building)
<optgroup label="{{ $building->title }}"></optgroup>
@foreach (Floor::whereIn('id', function($query){
$query->select('floor_id')
->from('rooms')
->where('building_id', $building->id)->distinct();
})->get() as $floor)
<option value="{{ $floor->id }}">{{ $floor->description }}</option>
@endforeach
@endforeach
</select>