I'm trying to use union() after I foreach the 2nd table. But it give me an error. Please see my code below.
Code
$customers = Customer::select(['email', 'name']); $clients = Client::select('email', 'name'])->get(); $total_clients = []; foreach($clients as $client) { if($status == 7 && $client->email != "j@domain.com" && $client->name == "A") { continue; } $total_clients[] = $client; } $all_clients = collect($total_clients); $customers->union($clients)->get(); Error
BadMethodCallException in Macroable.php line 74: Method getBindings does not exist.
Laravel Version
5.2
https://stackoverflow.com/questions/65767589/how-to-use-union-after-foreach-the-2nd-table-in-laravel January 18, 2021 at 08:58AM
没有评论:
发表评论