frontend\modules\user\models\UserMeta::saveNewMeta PHP Méthode

saveNewMeta() public méthode

添加新的动作
public saveNewMeta ( $type, $targetId, $do ) : boolean
$type
$targetId
$do
Résultat boolean
    public function saveNewMeta($type, $targetId, $do)
    {
        $data = ['target_id' => $targetId, 'user_id' => Yii::$app->user->id, 'target_type' => $type, 'type' => $do];
        $this->deleteAll($data);
        $model = $this->find()->where($data)->one();
        $this->setAttributes($data);
        if (!$model) {
            if ($this->save()) {
                return true;
            } else {
                return array_values($this->getFirstErrors())[0];
            }
        }
    }