Exemple #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\MatrixCol             $colModel
  * @param \rsanchez\Deep\Model\MatrixRow             $rowModel
  */
 public function __construct(ConnectionInterface $db, EntryCollection $collection, HydratorCollection $hydrators, $fieldtype, MatrixCol $colModel, MatrixRow $rowModel)
 {
     parent::__construct($db, $collection, $hydrators, $fieldtype);
     $this->colModel = $colModel;
     $this->rowModel = $rowModel;
     $fieldIds = $collection->getFieldIdsByFieldtype($fieldtype);
     $this->cols = $this->colModel->fieldId($fieldIds)->orderBy('col_order')->get();
     foreach ($this->cols as $col) {
         if (!isset($this->sortedCols[$col->field_id])) {
             $this->sortedCols[$col->field_id] = new MatrixColCollection();
         }
         $this->sortedCols[$col->field_id]->push($col);
     }
     $collection->setMatrixCols($this->cols);
 }
 public function testSetColsHidden()
 {
     $row = MatrixRow::find(1);
     $cols = MatrixCol::fieldId(13)->get();
     $row->setCols($cols);
     $array = $row->toArray();
     $this->assertArrayNotHasKey('col_id_1', $array);
 }
 public function testFieldIdScope()
 {
     $query = MatrixCol::fieldId(13)->get();
     $this->assertThat($query->fetch('col_id')->all(), new ArrayHasOnlyValuesConstraint([1, 2, 3]));
 }