Answers for "laravel distinct a collection by key"

PHP
1

laravel collection unique

$collection = collect([1, 1, 2, 2, 3, 4, 2]);

$unique = $collection->unique();

$unique->values()->all();

// [1, 2, 3, 4]
Posted by: Guest on July-24-2021
4

eloquent get distinct

$ad->getcodes()->distinct('pid')->count('pid');
Posted by: Guest on September-20-2020

Code answers related to "laravel distinct a collection by key"

Browse Popular Code Answers by Language