I want to perform additional operations when a set of function are called in a chain.
I have seen this happening in Laravel query builder but I wasn't able to find the incumbent logic behind it. It defines where clauses in a set, if they are chained and separate otherwise (In the whereNested function callback).
$q->whereNested(function (Builder $q) {
// Generates "Where (first = 1 and second = 2) or third = 3"
$q->where('first', 1)->where('second', 2);
$q->orWhere('third', 3);
});
Is there a way to know this while executing the function? If not, can someone point me to the logic used by Laravel?