Skip to content

Instantly share code, notes, and snippets.

@barryo
Created October 21, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryo/314798784c0956d6f8c8ae5a0ab1a1f3 to your computer and use it in GitHub Desktop.
Save barryo/314798784c0956d6f8c8ae5a0ab1a1f3 to your computer and use it in GitHub Desktop.
<?php
use IXP\Models\Customer;
// sample customer with ID 18:
$cust = Customer::find(18);
// iterate over the customer's contacts:
foreach( $cust->contacts as $c ) {
// and iterate over each contact's groups
foreach( $c->contactGroupsAll()->get() as $g ) {
echo "{$c->id} - {$g->id} - {$g->name} - {$g->type} - {$g->active}\n";
}
}
// if you want just contact roles, use:
// $c->contactRoles()->get()
// if you want just contact groups excluding roles, use:
// $c->contactGroups()->get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment