this is a simplified use case, only to illustrate what I want to achieve:
Considering this query in pure SQL:
SELECT url, 1 AS active
FROM `modules`
WHERE 1
How can I add the constant active column using query builder ?
Here is my Query Builder without the extra column:
DB::table('modules')
->get(['url']);
Simplest would be to use DB::raw
DB::table('modules')->get(['url', DB::raw('1 as active')]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With