本文整理汇总了PHP中yii\db\ActiveRecord::attributes方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::attributes方法的具体用法?PHP ActiveRecord::attributes怎么用?PHP ActiveRecord::attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fields
/**
* List of model fields displayed in form
*
* ```php
* return [
* 'id' => [
* 'class' => Input::className(),
* ],
* 'username' => [
* 'class' => Input::className(),
* ],
* 'status' => [
* 'class' => Select::className(),
* 'items' => [User::STATUS_ACTIVE => 'Active', User::STATUS_DELETED => 'Deleted'],
* ],
* ];
* ```
*
* Default is all model attributes with class = Input
*
* @return array
*/
public function fields()
{
$fields = [];
foreach ($this->model->attributes() as $attribute) {
$fields[$attribute] = ['class' => Input::className()];
}
return $fields;
}
示例2: attributes
/**
* @inheritdoc
*/
public function attributes()
{
if ($this->_i18n_enabled) {
return array_merge(parent::attributes(), $this->_getI18NAttributes());
}
return parent::attributes();
}
示例3: attributes
/**
* @inheritdoc
*/
public function attributes()
{
if ($this->_custom_attributes) {
return array_merge(parent::attributes(), $this->_custom_attributes);
} else {
return parent::attributes();
}
}
示例4: attributes
public function attributes()
{
$class = get_class($this);
if (!isset(self::$attributesCache[$class])) {
self::$attributesCache[$class] = parent::attributes();
}
return self::$attributesCache[$class];
}
示例5: find
public static function find()
{
$return = parent::find();
if (in_array('deleted_at', parent::attributes())) {
$tableName = static::getTableSchema()->name;
$return->andWhere([$tableName . '.deleted_at' => null]);
}
return $return;
}
示例6: getFields
public function getFields()
{
$fields = [];
$modelFields = count($this->activeRecord->fields()) > 0 ? $this->activeRecord->fields() : $this->activeRecord->attributes();
foreach ($modelFields as $key => $value) {
if (is_int($key)) {
$fields[] = $value;
} else {
$fields[] = $key;
}
}
return $fields;
}
示例7: loadModel
/**
* Populate model data
* @param ActiveRecord $model the model to populate
* @param array $modelData
* @return bool true if success
*/
public function loadModel($model, $modelData)
{
$model->trigger('beforeLoad');
if (empty($modelData)) {
return false;
}
$attributes = $model->attributes();
$b = false;
foreach ($attributes as $attrName) {
if (array_key_exists($attrName, $modelData)) {
$model->setAttribute($attrName, $modelData[$attrName]);
$b = true;
}
}
$model->trigger('afterLoad');
return $b;
}
示例8: attributes
public function attributes()
{
return array_merge(parent::attributes(), ['designationbien', 'designation bien', 'anneeRef', 'date acquisition', 'actif brut', 'amortissement pratiquee', 'valeur nette', 'prix cession', 'plus value', 'moins value', 'unité', 'type reforme', 'dat ereforme']);
}
示例9: attributes
/**
* @inheritdoc
*/
public function attributes()
{
return array_merge(parent::attributes(), ['datefin']);
}
示例10: getSearchableModelAttributes
/**
* @param ActiveRecord $model
* @param array $except
* @return \im\search\components\searchable\AttributeDescriptor[]
*/
protected function getSearchableModelAttributes($model, $except = [])
{
$searchableAttributes = [];
$attributes = $model->attributes();
$labels = $model->attributeLabels();
foreach ($attributes as $attribute) {
if (!in_array($attribute, $except)) {
$searchableAttributes[] = new AttributeDescriptor(['name' => $attribute, 'label' => isset($labels[$attribute]) ? $labels[$attribute] : $model->generateAttributeLabel($attribute)]);
}
}
return $searchableAttributes;
}
示例11: attributes
/**
* @inheritdoc
*/
public function attributes()
{
$attributes = parent::attributes();
$attributes[] = 'last_message_id';
return $attributes;
}
示例12: attributes
public function attributes()
{
return parent::attributes();
//eturn array_merge(parent::attributes(), ['publishers.name']);
}
示例13: attributes
public function attributes()
{
return array_merge(parent::attributes(), ['date mouvement', 'mouvement', 'affecté vers', 'transféré de', 'transféré vers', 'date fin reparation', 'type reforme', 'typereforme', 'anneeRef', 'dateRef', 'actifbrut', 'amortpratiquee', 'valeurnet', 'anneexercice', 'dotation', 'comptecomptable', 'datetrensfert', 'prixcession', 'unite', 'structure', 'compte comptable', 'designation compte', 'valeur brute', 'année exercice', 'dotation', 'amortissements cumulés', 'valeur nette', 'état', 'désignation', 'date enregistrement']);
}
示例14: attributes
public function attributes()
{
// add related fields to searchable attributes
return array_merge(parent::attributes(), ['searchText']);
}
示例15: attributes
public function attributes()
{
return array_merge(parent::attributes(), [$this->tableName() . '.users_count']);
}