diff --git a/README.md b/README.md index 1b114e8..bfed567 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ $counterparty = $counterparty->buildUpdate() ``` Product::query($sklad, QuerySpecs::create([ 'maxResults' => 25, - 'expand' => Expand::create([Employee::class]), + 'expand' => Expand::create([Employee::$entityName]), 'updatedFrom' => new CommonDate("2017-01-01"), 'updatedBy' => "admin@admin" ]))->getList(); diff --git a/src/Components/Query/AbstractQuery.php b/src/Components/Query/AbstractQuery.php index bc775a5..088ed34 100644 --- a/src/Components/Query/AbstractQuery.php +++ b/src/Components/Query/AbstractQuery.php @@ -23,7 +23,7 @@ abstract class AbstractQuery{ /** * @var Expand $expand */ - private $expand; + protected $expand = null; private $customQueryUrl = null; protected static $entityListClass; @@ -71,7 +71,9 @@ public function setRequestOptions(RequestConfig $options){ * @return QuerySpecs */ protected function attachExpand(QuerySpecs &$querySpecs){ - $querySpecs->expand = $this->expand; + if ( $this->expand !== null ){ + $querySpecs->expand = $this->expand; + } return $querySpecs; } diff --git a/src/Components/Query/EntityQuery.php b/src/Components/Query/EntityQuery.php index abee22d..92b68d6 100644 --- a/src/Components/Query/EntityQuery.php +++ b/src/Components/Query/EntityQuery.php @@ -12,10 +12,11 @@ class EntityQuery extends AbstractQuery { /** * Get entity by id * @param $id - * @param Expand|null $expand + * @param Expand|null $expand Deprecated, use withExpand() * @return AbstractEntity */ public function byId($id, Expand $expand = null){ + if ( !$expand ) $expand = $this->expand; $res = $this->getSkladInstance()->getClient()->get( ApiUrlRegistry::instance()->getByIdUrl($this->entityName, $id), ($expand?['expand'=>$expand->flatten()]:[]),