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