In this article, We will explain to you how to use the Union query in laravel(laravel eloquent Union query example). here we will give you a simple example of laravel eloquent Union query. The laravel eloquent provides many types of eloquent methods. the Union method two queries combine and return the data.
So you can see below the following example.
$student_1 = DB::table('students') ->select("students.first_name","students.last_name"); $student_2 = DB::table('standards') ->select("standards.name") ->union($student_1) ->get();
The unionAll method is also available and so same as the syntax of a union.
Please follow and like us: