Eloquent has no model-level UNION, but the query builder does. It works across two tables as long as both selects return the same columns in the same order.
union()
use Illuminate\Support\Facades\DB;
$out = DB::table('out_records')->select('date', 'amount', DB::raw("'out' as type"));
$rows = DB::table('in_records')
->select('date', 'amount', DB::raw("'in' as type"))
->union($out)
->orderBy('date')
->get();
The orderBy applies to the whole combined result, so rows from both tables are interleaved by date. The added type column tells you where each row came from.
union() against unionAll()
union() removes duplicate rows, unionAll() keeps them. If an income and an expense both have the same date and amount, union() returns one row. Use unionAll() when rows that look equal are different records.
Pagination
Wrap the union in a subquery, then order and page it:
$union = DB::table('in_records')->select('date', 'amount')
->unionAll(DB::table('out_records')->select('date', 'amount'));
$page = DB::query()->fromSub($union, 'u')->orderBy('date')->paginate(20);
To see the SQL, call ->toSql() on the builder. It is a single statement with union between two selects.
Tested on Laravel 10.x (PHP 8.1) and 12.x (PHP 8.3) with SQLite: the tests check ordering across both tables, duplicate removal against unionAll, the paged subquery form, and that the SQL has a single union. Source: tests/laravel-verification/files/q9489.