本文整理汇总了PHP中yii\db\ActiveRecord::fields方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::fields方法的具体用法?PHP ActiveRecord::fields怎么用?PHP ActiveRecord::fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fields
/**
* @inheritdoc
*/
public function fields()
{
$fields = parent::fields();
$fields['class_trainer_name'] = function () {
$trainer = $this->getTrainer()->toArray();
return $trainer['user_type'] === "studio" ? $trainer['payment']['payment_bussines_name'] : $trainer['payment']['payment_first_name'] . " " . $trainer['payment']['payment_last_name'];
};
$fields['stream'] = function () {
return $this->getStream();
};
$fields['pay_sum'] = function () {
return (int) $this->getSumPay();
};
$fields['pay_count'] = function () {
return (int) $this->getStudentCount();
};
$fields['activity_name'] = function () {
return $this->getActivity();
};
$fields['studio_trainer'] = function () {
return $this->getStudioTrainer();
};
if (Yii::$app->request->get('booking')) {
$fields['students'] = function () {
return $this->getStudentList();
};
}
return $fields;
}
示例2: fields
public function fields()
{
$fields = parent::fields();
$fields['title'] = 'titleLang';
$fields['description'] = 'description';
return $fields;
}
示例3: fields
/**
* 过滤最终返回的字段
*
* @author NJ 2016年8月1日15:21:44
* @return array 字段
*
*/
public function fields()
{
# code...
$fields = parent::fields();
unset($fields['code']);
return $fields;
}
示例4: fields
public function fields()
{
$fields = parent::fields();
// remove fields that contain sensitive information
unset($fields['auth_key'], $fields['password_hash'], $fields['password_reset_token']);
return $fields;
}
示例5: fields
public function fields()
{
$fields = parent::fields();
$fields[] = 'artist';
$fields[] = 'singleStyles';
return $fields;
}
示例6: fields
public function fields()
{
$fields = parent::fields();
error_log(print_r($fields, 1));
unset($fields['password']);
return $fields;
}
示例7: fields
public function fields()
{
$fields = parent::fields();
$fields['bookings_count'] = function () {
return (int) $this->getBookingsCount();
};
return $fields;
}
示例8: fields
public function fields()
{
$fields = parent::fields();
$fields['cover'] = function ($model) {
return file_exists($model->getCoverPath()) ? $model->getCoverPath() : '';
};
return $fields;
}
示例9: fields
/**
* @inheritdoc
*/
public function fields()
{
$fields = parent::fields();
unset($fields['auth_key']);
unset($fields['password_hash']);
unset($fields['password_reset_token']);
return $fields;
}
示例10: fields
public function fields()
{
$fields = parent::fields();
/* $fields['code'] = function ($model) {
return (new District())->getCodeById($model->district_id);
}; */
//unset($fields['created_by'],$fields['updated_by'],$fields['created_at'],$fields['updated_at']);
return $fields;
}
示例11: fields
/**
* @inheritdoc
*/
public function fields()
{
$fields = parent::fields();
unset($fields['tree'], $fields['lft'], $fields['rgt'], $fields['depth']);
$fields['hasChildren'] = function ($model) {
/** @var Tree $model */
return $model->children(1)->count() > 0;
};
return $fields;
}
示例12: fields
public function fields()
{
$fields = parent::fields();
unset($fields['mem']);
return array_merge($fields, ['data', 'date' => function () {
return Time::dateNormalize($this->created);
}, 'model' => function () {
return $this->getData()->getModel();
}]);
// TODO: Change the autogenerated stub
}
示例13: fields
/**
* @inheritdoc
*/
public function fields()
{
$fields = parent::fields();
$fields['sender'] = function () {
return $this->getSender();
};
$fields['receiver'] = function () {
return $this->getReceiver();
};
return $fields;
}
示例14: fields
public function fields()
{
$fields = parent::fields();
$fields['password'] = function () {
return '******';
};
$fields['roles'] = function () {
return \yii\helpers\ArrayHelper::getColumn(Yii::$app->authManager->getRolesByUser($this->id), 'name');
};
unset($fields['auth_key'], $fields['access_token']);
return $fields;
}
示例15: fields
/**
* @inheritdoc
*/
public function fields()
{
$result = parent::fields();
unset($result['auth_key']);
unset($result['fb_uid']);
unset($result['role']);
unset($result['status']);
if (isset($result['gender'])) {
$result['gender'] = 'genderName';
}
return $result;
}