We can add subquery or "custom column" in select with first argument of \Illuminate\Database\Query\Builder::selectSub method as raw SQL or Closure, or \Illuminate\Database\Query\Builder. Better solution is closure or Builder.
In your case it will be:
$modules = DB::table('modules')->select('url')
->selectSub(function ($query) {
$query->selectRaw('1');
}, 'active')
->get();
Tested on Laravel 5.5. In closure $query is a object of \Illuminate\Database\Query\Builder for subquery. Prepared SQL will be:
select `url`, (select 1) as `active` from `modules`
Extended example... If we use App\Module eloquent for modules and we need get url of modules and count of their submodules with id > 5, we can write next:
$modules = App\Module::select('url')
->selectSub(function ($query) {
/** @var $query \Illuminate\Database\Query\Builder */
$query->from('submodules')
->selectRaw('COUNT(*)')
->where('id', '>', 5)
->whereRaw('`modules`.`id` = `submodules`.`module_id`');
}, 'countOfSubModules')
->get();
Prepared SQL will be:
select `url`,
(select COUNT(*) from `submodules`
where `id` > ? and `modules`.`id` = `submodules`.`module_id`)
as `countOfSubModules`
from `modules`
Or you can write your example with raw sql:
$sql = 'SELECT 1';
$modules = DB::table('modules')->select('url')->selectSub($sql, 'active')->get();
Then prepared SQL will be:
select `id`, (SELECT 1) as `active` from `modules`
For get all columns necessarily to use select('*'):
App\Module::select('*')->selectSub($sql, 'text')->get();
Not:
App\Module::selectSub($sql, 'text')->get();