public function rules()
 {
     $rules = [];
     $message = 'You have added it.';
     if (!is_array($this->contentAttribute)) {
         $rules = ['user_content_unique' => [[$this->createdByAttribute, $this->contentAttribute], 'unique', 'targetAttribute' => [$this->createdByAttribute, $this->contentAttribute], 'message' => $message]];
     } elseif (is_array($this->contentAttribute)) {
         $rules = ['user_content_unique' => [array_merge([$this->createdByAttribute], $this->contentAttribute), 'unique', 'targetAttribute' => array_merge([$this->createdByAttribute], $this->contentAttribute), 'message' => $message]];
     }
     return array_merge(parent::rules(), $rules);
 }
Beispiel #2
0
 public function rules()
 {
     return array_merge(parent::rules(), $this->getAdditionalRules());
 }