Пример #1
0
 /**
  * {@inheritdoc}
  *
  * @param \Illuminate\Database\ConnectionInterface   $db
  * @param \rsanchez\Deep\Collection\EntryCollection  $collection
  * @param \rsanchez\Deep\Hydrator\HydratorCollection $hydrators
  * @param string                                     $fieldtype
  * @param \rsanchez\Deep\Model\RelationshipEntry     $model
  */
 public function __construct(ConnectionInterface $db, EntryCollection $collection, HydratorCollection $hydrators, $fieldtype, RelationshipEntry $model)
 {
     parent::__construct($db, $collection, $hydrators, $fieldtype);
     $this->model = $model;
     $this->relationshipCollection = $this->model->siblings($collection->modelKeys())->get();
     foreach ($this->relationshipCollection as $entry) {
         if (!isset($this->entries[$entry->sibling_id])) {
             $this->entries[$entry->sibling_id] = array();
         }
         $this->entries[$entry->sibling_id][] = $entry;
     }
     // add these entry IDs to the main collection
     $collection->addEntryIds($this->relationshipCollection->modelKeys());
 }
Пример #2
0
 /**
  * {@inheritdoc}
  *
  * @param \Illuminate\Database\ConnectionInterface   $db
  * @param \rsanchez\Deep\Collection\EntryCollection  $collection
  * @param \rsanchez\Deep\Hydrator\HydratorCollection $hydrators
  * @param string                                     $fieldtype
  * @param \rsanchez\Deep\Model\RelationshipEntry     $model
  */
 public function __construct(ConnectionInterface $db, EntryCollection $collection, HydratorCollection $hydrators, $fieldtype, RelationshipEntry $model)
 {
     parent::__construct($db, $collection, $hydrators, $fieldtype);
     $this->model = $model;
     $this->relationshipCollection = $this->model->parentEntryId($collection->modelKeys())->orderBy('order')->get();
     foreach ($this->relationshipCollection as $entry) {
         $type = $entry->grid_field_id ? 'grid' : 'entry';
         $entityId = $entry->grid_field_id ? $entry->grid_row_id : $entry->parent_id;
         $propertyId = $entry->grid_field_id ? $entry->grid_col_id : $entry->field_id;
         if (!isset($this->entries[$type][$entityId][$propertyId])) {
             $this->entries[$type][$entityId][$propertyId] = array();
         }
         $this->entries[$type][$entityId][$propertyId][] = $entry;
     }
     // add these entry IDs to the main collection
     $collection->addEntryIds($this->relationshipCollection->modelKeys());
 }