1 2 3 4 5 6 7 |
foreach ($question->tags as $tag) { if (!isset($related)) { $related = $tag->questions; } else { $related = $related->merge($tag->questions); } } |
How to merge two eloquent collections? – Laravel.io – The Laravel Community Portal
https://laravel.io/index.php/forum/05-29-2015-how-to-merge-two-eloquent-collections