I have the following Eloquent query (This is a simplified version of a query which consists of of more wheres and orWheres hence the apparent round
This is how you do a subquery where:
$q->where('price_date', function($q) use ($start_date)
{
$q->from('benchmarks_table_name')
->selectRaw('min(price_date)')
->where('price_date', '>=', $start_date)
->where('ticker', $this->ticker);
});
Unfortunately orWhere requires explicitly provided $operator, otherwise it will raise an error, so in your case:
$q->orWhere('price_date', '=', function($q) use ($start_date)
{
$q->from('benchmarks_table_name')
->selectRaw('min(price_date)')
->where('price_date', '>=', $start_date)
->where('ticker', $this->ticker);
});
EDIT: You need to specify from in the closure in fact, otherwise it will not build correct query.