How to reuse parts of Eloquent builder in Laravel
$shared = TableA::join('tableb', 'tablea.bid', '=', tableb.id)
->join('talbec', 'tableb.cid', '=', tablec.id)
->join('tabled', 'tablec.did', '=', tabled.id);
$a = $shared->clone()->where('tablea_col', '=', true)->get();
$b = shared->clone()->where('tableb_col', '=', true)->get();
before Laravel 8, use
$a = clone $shared;
$b = clone $shared;
$a = $a->where('tablea_col', '=', true)->get();
$b = $b->where('tableb_col', '=', true)->get();