I'm working on Laravel 4. As I knew, I can do subquery:
Project::whereIn('project_id', function($q) {
$q->select('project_id')
->from('company')
->whereNull('deleted_at');
});
I found complications, that I can't use scope in subquery and disable soft_delete make me change source code so much.
I wish it was:
Project::whereIn('project_id', function(&$q) {
$q = Company::select('project_id')->getQuery();
});
Now, I can add scope, disable soft_delete easily.
I tried, and found a solution, that I must change Laravel's Database\Query\Builder code, function whereInSub, line 786.
call_user_func($callback, $query = $this->newQuery());
to:
$query = $this->newQuery();
call_user_func_array($callback, array(&$query));
It's harmful to modify Laravel framework's vendor. So I want to ask how to do it safely.
Sorry because my bad English.
Thank you for reading.