contacts array sorter

This commit is contained in:
David Bomba 2016-04-17 20:53:53 +10:00
parent 7f6f34b302
commit d19c43edce

View File

@ -8,7 +8,6 @@ use App\Models\Contact;
use App\Models\Activity;
use App\Events\ClientWasCreated;
use App\Events\ClientWasUpdated;
use Illuminate\Support\Facades\Log;
class ClientRepository extends BaseRepository
{
@ -100,13 +99,11 @@ class ClientRepository extends BaseRepository
$first = true;
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
$contactIds = [];
usort($contacts, function ($left, $right) {
return $right['is_primary'] - $left['is_primary'];
});
Log::info($contacts);
foreach ($contacts as $contact) {
$contact = $client->addContact($contact, $first);
$contactIds[] = $contact->public_id;