本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::getDates方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getDates方法的具体用法?PHP Model::getDates怎么用?PHP Model::getDates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::getDates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* 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);
}
示例2: pluck
/**
* 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};
});
}
示例3: getVisibleIndexDates
/**
* 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());
}
示例4: getDates
/**
* 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();
}
示例5: getDates
/**
* Get the attributes that should be converted to dates.
*
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), ['birthday']);
}
示例6: getDates
/**
* Get the attributes that should be converted to dates.
*
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), ['started_at', 'completed_at']);
}
示例7: getPropertiesFromTable
/**
* 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);
}
}
}
}
}
示例8: getDates
/**
* Get the attributes that should be converted to dates.
*
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), array('oauth2_expires'));
}
示例9: getDates
public function getDates()
{
return array_merge(parent::getDates(), ['start_date', 'next_date']);
}
示例10: getDates
/**
* Get the attributes that should be converted to dates.
*
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), [static::PUBLISHED_AT]);
}
示例11: getDates
public function getDates()
{
return array_merge(parent::getDates(), ['expire_at']);
}
示例12: findDateColumns
/**
* 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']));
}
示例13: getDates
/**
* 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'));
}
示例14: __construct
/**
* 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();
}
示例15: getDates
/**
* Get the attributes that should be converted to dates.
*
* @return array
*/
public function getDates()
{
return array_merge(parent::getDates(), array('activated_at', 'last_login'));
}