Laravel – How to merge two or more query results? #laravel #mergetwoobjects

$user=User::where(‘age’=’10’)->get();

$recentuser=User::where(‘date’=’10’)->get();

$mergevalue=$user->toArray()+$recrnyuser->toArray();

$users=User:: hybrid ($mergevalue);

  1. Gets query results
  2. Merge the two results by converting to array
  3. Using hybrid function convert back to user model

That’s the solution for meeting two or more query results.