public function onAfterWrite()
    {
        parent::onAfterWrite();

        if ($this->Default) {
            foreach ($this->Contact()->Locations() as $location) {
                if ($location->ID != $this->ID && $location->Default) {
                    $location->Default = false;
                    $location->write();
                }
            }
        }
    }
public function onAfterWrite()
    {
        parent::onAfterWrite();

        if ($this->Default) {
            foreach ($this->Contact()->Locations() as $location) {
                if ($location->ID != $this->ID && $location->Default) {
                    $location->Default = false;
                    $location->write();
                }
            }
        }
    }
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( $ this -> Default ) { foreach ( $ this -> Contact ( ) -> Locations ( ) as $ location ) { if ( $ location -> ID != $ this -> ID && $ location -> Default ) { $ location -> Default = false ; $ location -> write ( ) ; } } } }
If we have assigned this as a default location, loop through
other locations and disable default.

@return void
If we have assigned this as a default location loop through other locations and disable default .