$querySell = Borrow::with(['userData','recordData','customerData','borrowInfoData'])
// ->setAppends(['type' => 'sell'])
->wheres($sql)
->select('id','number','state','time','amount','total','user','examine','type','data','customer','borrow_nums','borrow_restore_nums',DB::raw("-1 as nums"));
// $xk = DB::table('sells')
// ->leftJoin('users','users.id', '=', 'sells.user')
// ->wheres($sql)
// ->select('sells.id', 'sells.number','sells.time','sells.amount','sells.total','sells.user','users.name',DB::raw('"sell" as type'));
$querySre = BorrowRestore::with(['userData','recordData','customerData','borrowRestoreInfoData'])
// ->setAppends(['type' => 'sre'])
->wheres($sql)
->select('id','number','state','time','amount','total','user','examine','type','data','customer',DB::raw("-1 as borrow_nums"),DB::raw("-1 as borrow_restore_nums"),'nums');
$unionAllQuery = $querySell->unionAll($querySre);
12-21
2580
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-02
5199
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-05
1852
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)