The above doest work separately. $queryUnread executes below query
select * from activities_notifiers where read_at is null and read_at is not null order by id desc limit 5
The $queryUnread is having both whereNull and whereNotNull condition. What is the correct way of using builder especially when we have to build query based on different condition?
In your example the query is build by reference. Basically $queryUnread and $queryRead point to the same reference. Because of this you see both statements in the final query.
Both approaches result in two Builder instances, yes. If the base query \App\UserActivity::select($select)->orderBy('users_activities.id', 'desc') was a little more complex, then one might make a stronger argument for cloning