getDates() public method

Get the attributes that should be converted to dates.
public getDates ( ) : array
return array
Example #1
0
 /**
  * Format the value of a model attribute.
  *
  * Looks for $this->formatColumnName() methods.
  *
  * Note that the model's date/time attributes are automatically passed
  * through $this->__carbon().
  *
  * @param string $name
  * @param array $args
  * @return mixed
  */
 public function __call($name, array $args = [])
 {
     $method = 'format' . studly_case($name);
     if (method_exists($this, $method)) {
         return $this->{$method}();
     }
     $name = snake_case($name);
     if (in_array($name, $this->model->getDates())) {
         return $this->__carbon($name, data_get($args, 0), data_get($args, 1));
     }
     return data_get($this->model, $name);
 }
Example #2
0
 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string|null  $key
  * @return \Illuminate\Support\Collection
  */
 public function pluck($column, $key = null)
 {
     $results = $this->toBase()->pluck($column, $key);
     // If the model has a mutator for the requested column, we will spin through
     // the results and mutate the values so that the mutated version of these
     // columns are returned as you would expect from these Eloquent models.
     if (!$this->model->hasGetMutator($column) && !$this->model->hasCast($column) && !in_array($column, $this->model->getDates())) {
         return $results;
     }
     return $results->map(function ($value) use($column) {
         return $this->model->newFromBuilder([$column => $value])->{$column};
     });
 }
Example #3
0
 /**
  * Get the visible model date attributes for the index.
  *
  * @param  \Illuminate\Database\Eloquent\Model $model
  * @return array
  */
 protected function getVisibleIndexDates(BaseModel $model)
 {
     if (count($model->getVisible()) > 0) {
         return array_intersect($model->getDates(), $model->getVisible());
     }
     return array_diff($model->getDates(), $model->getHidden());
 }
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     $this->getFields()->each(function ($field) {
         if ($field instanceof FieldTypeDateInterface) {
             $this->dates[] = $field->getDBKey();
         }
     });
     if ($this->hasField(static::CREATED_AT) and $this->hasField(static::UPDATED_AT)) {
         $this->timestamps = true;
     }
     return parent::getDates();
 }
Example #5
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), ['birthday']);
 }
Example #6
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), ['started_at', 'completed_at']);
 }
 /**
  * Load the properties from the database table.
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  */
 protected function getPropertiesFromTable($model)
 {
     $table = $model->getConnection()->getTablePrefix() . $model->getTable();
     $schema = $model->getConnection()->getDoctrineSchemaManager($table);
     $databasePlatform = $schema->getDatabasePlatform();
     $databasePlatform->registerDoctrineTypeMapping('enum', 'string');
     $platformName = $databasePlatform->getName();
     $customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
     foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
         $databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
     }
     $database = null;
     if (strpos($table, '.')) {
         list($database, $table) = explode('.', $table);
     }
     $columns = $schema->listTableColumns($table, $database);
     if ($columns) {
         foreach ($columns as $column) {
             $name = $column->getName();
             if (in_array($name, $model->getDates())) {
                 $type = 'datetime';
             } else {
                 $type = $column->getType()->getName();
             }
             if (!($model->incrementing && $model->getKeyName() === $name) && $name !== $model::CREATED_AT && $name !== $model::UPDATED_AT) {
                 if (!method_exists($model, 'getDeletedAtColumn') || method_exists($model, 'getDeletedAtColumn') && $name !== $model->getDeletedAtColumn()) {
                     $this->setProperty($name, $type);
                 }
             }
         }
     }
 }
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), array('oauth2_expires'));
 }
Example #9
0
 public function getDates()
 {
     return array_merge(parent::getDates(), ['start_date', 'next_date']);
 }
Example #10
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), [static::PUBLISHED_AT]);
 }
Example #11
0
 public function getDates()
 {
     return array_merge(parent::getDates(), ['expire_at']);
 }
Example #12
0
 /**
  * Get any additional date columns for this model.
  *
  * @param Model $instance
  * @return array
  */
 protected function findDateColumns(Model $instance)
 {
     return array_values(array_diff($instance->getDates(), ['created_at', 'updated_at', 'deleted_at']));
 }
Example #13
0
 public function getDates()
 {
     return array_merge(parent::getDates(), ['deadline', 'paid_date']);
 }
Example #14
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), array('last_attempt_at', 'suspended_at', 'banned_at'));
 }
Example #15
0
 /**
  * View model constructor.
  *
  * @param Model $model
  * @return ViewModel
  */
 public function __construct(Model $model)
 {
     $this->model = $model;
     $this->dates = array_merge($this->dates, $model->getDates());
     $this->buildRelations();
 }
Example #16
0
	/**
	 * Get the attributes that should be converted to dates.
	 *
	 * @return array
	 */
	public function getDates()
	{
		return array_merge(parent::getDates(), array('activated_at', 'last_login'));
	}
Example #17
0
 public function getDates()
 {
     return array_merge(parent::getDates(), ['published_date']);
 }
Example #18
0
 /**
  * Load the properties from the database table.
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  */
 protected function getPropertiesFromTable($model)
 {
     $table = $model->getConnection()->getTablePrefix() . $model->getTable();
     $schema = $model->getConnection()->getDoctrineSchemaManager($table);
     $schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     $columns = $schema->listTableColumns($table);
     if ($columns) {
         foreach ($columns as $column) {
             $name = $column->getName();
             if (in_array($name, $model->getDates())) {
                 $type = '\\Carbon\\Carbon';
             } else {
                 $type = $column->getType()->getName();
                 switch ($type) {
                     case 'string':
                     case 'text':
                     case 'date':
                     case 'time':
                     case 'guid':
                     case 'datetimetz':
                     case 'datetime':
                         $type = 'string';
                         break;
                     case 'integer':
                     case 'bigint':
                     case 'smallint':
                         $type = 'integer';
                         break;
                     case 'decimal':
                     case 'float':
                         $type = 'float';
                         break;
                     case 'boolean':
                         $type = 'boolean';
                         break;
                     default:
                         $type = 'mixed';
                         break;
                 }
             }
             $this->setProperty($name, $type, true, true);
             $this->setMethod(Str::camel("where_" . $name), '\\Illuminate\\Database\\Query\\Builder|\\' . get_class($model), array('$value'));
         }
     }
 }
Example #19
0
 /**
  * Get Dates
  *
  * Overloads the defined database fields which ought to be converted to
  * Carbon objects in order to add deleted_at as a default.
  * @return array Column names to transform.
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), ['deleted_at']);
 }
Example #20
0
 /**
  * Load the properties from the database table.
  *
  * @param \Illuminate\Database\Eloquent\Model $model
  */
 protected function getPropertiesFromTable($model)
 {
     $table = $model->getConnection()->getTablePrefix() . $model->getTable();
     $schema = $model->getConnection()->getDoctrineSchemaManager($table);
     $databasePlatform = $schema->getDatabasePlatform();
     $databasePlatform->registerDoctrineTypeMapping('enum', 'string');
     $platformName = $databasePlatform->getName();
     $customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
     foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
         $databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
     }
     $database = null;
     if (strpos($table, '.')) {
         list($database, $table) = explode('.', $table);
     }
     $columns = $schema->listTableColumns($table, $database);
     if ($columns) {
         foreach ($columns as $column) {
             $name = $column->getName();
             if (in_array($name, $model->getDates())) {
                 $type = '\\Carbon\\Carbon';
             } else {
                 $type = $column->getType()->getName();
                 switch ($type) {
                     case 'string':
                     case 'text':
                     case 'date':
                     case 'time':
                     case 'guid':
                     case 'datetimetz':
                     case 'datetime':
                         $type = 'string';
                         break;
                     case 'integer':
                     case 'bigint':
                     case 'smallint':
                         $type = 'integer';
                         break;
                     case 'decimal':
                     case 'float':
                         $type = 'float';
                         break;
                     case 'boolean':
                         $type = 'boolean';
                         break;
                     default:
                         $type = 'mixed';
                         break;
                 }
             }
             $comment = $column->getComment();
             $this->setProperty($name, $type, true, true, $comment);
             $this->setMethod(Str::camel("where_" . $name), '\\Illuminate\\Database\\Query\\Builder|\\' . get_class($model), array('$value'));
         }
     }
 }
Example #21
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), ['joined_at', 'left_at']);
 }