255, ], [ [ 'user_id' ], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => [ 'user_id' => 'id' ], ], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'user_id' => 'User ID', 'title' => 'Назва', 'creation_date' => 'Дата створення', 'code' => 'Шифр', 'genre' => 'Жанр', 'registration_date' => 'Дата реєстрації', 'contract' => 'Договір', 'type' => 'Тип', 'author_role' => 'Роль автора', ]; } /** * @return \yii\db\ActiveQuery */ public function getCreativeRoles() { return $this->hasMany(CreativeRole::className(), [ 'intellectual_property_id' => 'id' ]); } public function getCreativeRole() { return $this->hasOne(CreativeRole::className(), [ 'intellectual_property_id' => 'id' ]) ->where([ 'user_id' => \Yii::$app->user->id ]); } /** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); } /** * @return \yii\db\ActiveQuery */ public function getReports() { return $this->hasMany(Report::className(), [ 'intellectual_property_id' => 'id' ]); } }