本文整理汇总了PHP中yii\db\ActiveRecord::extraFields方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::extraFields方法的具体用法?PHP ActiveRecord::extraFields怎么用?PHP ActiveRecord::extraFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::extraFields方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extraFields
/**
* @inheritdoc
*/
public function extraFields()
{
$fields = parent::extraFields();
$fields['roles'] = function (Account $Model) {
$result = [];
$roles = AuthManager()->getRolesByUser($Model->id);
foreach ($roles as $role => $conf) {
$result[$role] = true;
}
$result[\common\Roles::USER] = true;
return $result;
};
$fields['permissions'] = function (Account $Model) {
$result = [];
$permissions = AuthManager()->getPermissionsByUser($Model->id);
foreach ($permissions as $permission => $conf) {
$result[$permission] = true;
}
return $result;
};
$fields['properties'] = function (Account $Model) {
return $Model->properties();
};
return $fields;
}
示例2: getExtraFields
public function getExtraFields()
{
$extraFields = [];
$modelExtraFields = $this->activeRecord->extraFields();
foreach ($modelExtraFields as $key => $value) {
if (is_int($key)) {
$extraFields[] = $value;
} else {
$extraFields[] = $key;
}
}
return $extraFields;
}
示例3: extraFields
public function extraFields()
{
return parent::extraFields();
}
示例4: extraFields
public function extraFields()
{
$extraFields = parent::extraFields();
$extraFields[] = 'contents';
return $extraFields;
}
示例5: extraFields
public function extraFields()
{
$relation = array_keys($this->getModelRelations());
$relation = array_combine($relation, $relation);
return array_merge(parent::extraFields(), $relation);
}