I have a object (Illuminate\Database\Eloquent\Builder) that have a (Illuminate\Database\Query\Builder) inside it. I dump the object and can see this:
The image bellow, is a dd($querybuilder) from the object
My plan is to get the query and extract the selected columns but I already tried ($querybuilder->query) and ($querybuilder['query']) and I received errors.
How can I get the "columns" value?
Solved. Thank you Tim Lewis
$query->getQuery()->columns worked!
Im posting where what im tying to do. select and addSelect are not doing what I wanted if no colunms are selected.
public function scopeAddStatusColumn($query)
{
$previous_columns = $query->getQuery()->columns;
$status_column = DB::raw('(begin <= NOW() AND end >= NOW()) OR (begin <= NOW() AND end IS NULL) as status');
$new_columns = $previous_columns == null ? ['*', $status_column] : [$previous_columns] + [$status_column];
$query = $query->select($new_columns);
return $query;
}