Combine 5 tables in Laravel and sort by created_at

旧街凉风 提交于 2019-12-02 08:40:10

I don't believe there would be any useful things you can do to the query. Unions require all queries to return the same amount of columns, you probably don't want to join these tables because that would just be a confused mess. I believe the best solution would be to use Collections.

$collection = new \Illuminate\Support\Collection();
$sortedCollection = $collection->merge($pets)->merge($cars)->merge($realEsate)->sortBy('created_at');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!