I have two collections and want to find the same or duplicated items inside two collections. My solution is first merging two collections and create one collection and then using duplicates method find the same items, but I have an error.
$t1 = collect([12, 13, 11]);
$t2 = collect([14, 15, 12, 11]);
$t3 = $t1->merge($t2);
$final = $t3->duplicates();
Error
BadMethodCallException Method Illuminate\Support\Collection::duplicates does not exist.