Skip to content
Advertisement

Laravel – Add custom column in select with Eloquent query buider

this is a simplified use case, only to illustrate what I want to achieve:

Considering this query in pure SQL:

How can I add the constant active column using query builder ?

Here is my Query Builder without the extra column:

Advertisement

Answer

Simplest would be to use DB::raw

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement