Inheritance: extends Model, use trait Isswp101\Persimmon\Traits\Elasticsearchable, use trait Isswp101\Persimmon\Traits\Paginationable, use trait Isswp101\Persimmon\Traits\Relationshipable
コード例 #1
0
 /**
  * Return parent model.
  *
  * @throws ParentModelNotFoundException
  * @return ElasticsearchModel
  */
 public function getOrFail()
 {
     $model = $this->get();
     if (is_null($model)) {
         throw new ParentModelNotFoundException($this->parentClass, $this->child->getParentId());
     }
     return $model;
 }
コード例 #2
0
 /**
  * Find model by id.
  *
  * @param mixed $id
  * @return ElasticsearchModel|null
  */
 public function find($id)
 {
     $child = $this->childClassName;
     $model = $child::findWithParentId($id, $this->parent->getId());
     if ($model) {
         $model->setParent($this->parent);
     }
     return $model;
 }
コード例 #3
0
 /**
  * Set parent document.
  *
  * @param ElasticsearchModel $parent
  */
 public function setParent(ElasticsearchModel $parent)
 {
     $this->_parent = $parent;
     $this->setParentId($parent->getId());
 }