Highlighted part:
where( DB::raw('1'), '<', function ($q) {
$q->from('items as i2')
->selectRaw('count(id)')
->whereRaw('i1.name = i2.name');
})
or if it's defined in model scope, then you may use this:
$table = 'i1';
...
where( DB::raw('1'), '<', function ($q) use ($table) {
$q->from("{$this->table} as i2")
->selectRaw("count({$this->getKeyName})")
->whereRaw("{$table}.name = i2.name");
})
Thanks very much! I'm using your first example and it works.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community