本文整理匯總了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']);
}