How can I use sql UNION
operator in eloquent ORM? I know I can use it in Illuminate\Database\Query\Builder
, but I want to do it with eloquent. I couldn't find anything about it in documentation neither in google. is it possible to do it?
Asked
Active
Viewed 2,797 times
2

devnull Ψ
- 3,779
- 7
- 26
- 43
-
3Eloquent ORM doesn't have `union` method. Please describe what exactly you want to do. – Alexey Mezenin Dec 27 '17 at 13:39
-
2Possible duplicate of [Laravel Eloquent Union query](https://stackoverflow.com/questions/41756404/laravel-eloquent-union-query) – ndrwnaguib Dec 27 '17 at 13:43
-
I'm trying to union multiple(two) queries, I dont want to send 2 quires – devnull Ψ Dec 27 '17 at 13:45
-
1You could combine two eloquent collections but it doesnt have union method – Luis felipe De jesus Munoz Dec 27 '17 at 13:46
-
@devnull what's wrong with sending two queries to get two collections (nested or separate)? – Alexey Mezenin Dec 27 '17 at 13:53
-
I'm trying to do simple thing and that's why don't want to send 2 queries, also I need relations and mutators, thats why I don't choose `querybuilder`, but as I see I will have to send 2 queries – devnull Ψ Dec 27 '17 at 13:56
-
Forget about how many queries you send. Eloquent uses a lot of queries when getting data so... – Luis felipe De jesus Munoz Dec 27 '17 at 14:07