Exemple #1
0
 function it_can_return_a_single_column(Column $column)
 {
     $column->getName()->willReturn('Column');
     $this->addColumn($column);
     $this->getColumn('Column')->shouldBe($column);
 }
 /**
  * Returns a `FormItem` based on the type of the `Column`.
  *
  * @param Model     $model  The `Model` which contains given `Column`.
  * @param Column    $column The `Column` to create a `FormItem` for.
  * @param \Eloquent $item   The instance to retrieve information from for filling the `FormItem`.
  *
  * @return FormItem The created `FormItem`.
  */
 private function createFromType(Model $model, Column $column, $item)
 {
     $result = null;
     switch ($column->getType()) {
         case Type::TEXT:
         case Type::TARRAY:
         case Type::SIMPLE_ARRAY:
         case Type::JSON_ARRAY:
         case Type::OBJECT:
         case Type::BLOB:
             $result = new TextAreaFormItem();
             break;
         case Type::INTEGER:
         case Type::SMALLINT:
         case Type::BIGINT:
             $result = new IntegerFormItem();
             break;
         case Type::DECIMAL:
         case Type::FLOAT:
             $result = new NumberFormItem();
             break;
         case Type::BOOLEAN:
             $result = new CheckboxFormItem();
             break;
         case Type::DATE:
             $result = new DateFormItem();
             break;
         case Type::DATETIME:
         case Type::DATETIMETZ:
             $result = new DateTimeFormItem();
             break;
         case Type::TIME:
             $result = new TimeFormItem();
             break;
         case Type::STRING:
         case Type::GUID:
         default:
             $result = new TextFormItem();
             break;
     }
     $columnName = $column->getName();
     $result->setName($columnName);
     $result->setLabel(Lang::trans($this->aujaConfigurator->getColumnDisplayName($model, $columnName)));
     if ($item != null && isset($item->{$columnName})) {
         $result->setValue($item->{$columnName});
     }
     return $result;
 }