src/Daursu/Xero/models/BaseModel.php
public function setRelationship($value, $key = '')
	{
		if (is_array($value)) {

			$class = __NAMESPACE__ . '\\' . str_singular($key);

			if (class_exists($class)) {

				// Check to see if the key value is plural or singular
				// if it is plural then we create a collection
				// otherwise we instantiate the class and add a single item to the relationship
				if (str_singular($key) == $key) {
					$this->addRelationship(new $class($value));
				}
				else {
					$collection = $class::newCollection($value);
					$this->addRelationship($collection);
				}
			}
		}
		elseif ($value instanceof Collection) {
			$this->addRelationship($value);
		}
		elseif ($value instanceof BaseModel) {
			$this->addRelationship($value);
		}
	}
public function setRelationship($value, $key = '')
	{
		if (is_array($value)) {

			$class = __NAMESPACE__ . '\\' . str_singular($key);

			if (class_exists($class)) {

				// Check to see if the key value is plural or singular
				// if it is plural then we create a collection
				// otherwise we instantiate the class and add a single item to the relationship
				if (str_singular($key) == $key) {
					$this->addRelationship(new $class($value));
				}
				else {
					$collection = $class::newCollection($value);
					$this->addRelationship($collection);
				}
			}
		}
		elseif ($value instanceof Collection) {
			$this->addRelationship($value);
		}
		elseif ($value instanceof BaseModel) {
			$this->addRelationship($value);
		}
	}
public function setRelationship ( $ value , $ key = '' ) { if ( is_array ( $ value ) ) { $ class = __NAMESPACE__ . '\\' . str_singular ( $ key ) ; if ( class_exists ( $ class ) ) { // Check to see if the key value is plural or singular // if it is plural then we create a collection // otherwise we instantiate the class and add a single item to the relationship if ( str_singular ( $ key ) == $ key ) { $ this -> addRelationship ( new $ class ( $ value ) ) ; } else { $ collection = $ class :: newCollection ( $ value ) ; $ this -> addRelationship ( $ collection ) ; } } } elseif ( $ value instanceof Collection ) { $ this -> addRelationship ( $ value ) ; } elseif ( $ value instanceof BaseModel ) { $ this -> addRelationship ( $ value ) ; } }
Sets the relationships on this model,
which in fact are collections of other models

@param string $key
@param array $value
Sets the relationships on this model which in fact are collections of other models