/
peyli
/
Practice
Обзор
Документация
Войти
/
peyli
/
Practice
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
models/Participant.php
85 строк
2 KB
Катя
Полный код
27 июн 2026, 14:28
27 июн 2026, 14:28
6181a72
Код
Авторство
О чём код?
<?php namespace app\models; use Yii; use yii\helpers\Html; /** * This is the model class for table "participant". * * @property int $id * @property string $user_username * @property int $event_id * @property string $role * @property string|null $created_at * * @property Event $event * @property User $userUsername */ class Participant extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ public static function tableName() { return 'participant'; } /** * {@inheritdoc} */ public function rules() { return [ [['user_username', 'event_id', 'role'], 'required'], [['event_id'], 'integer'], [['created_at'], 'safe'], [['user_username', 'role'], 'string', 'max' => 255], [['user_username'], 'default', 'value' => Yii::$app->user->identity->username], [['user_username'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_username' => 'username']], [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::class, 'targetAttribute' => ['event_id' => 'id']], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'user_username' => 'Логин', 'event_id' => 'Мероприятие', 'role' => 'Роль', 'created_at' => 'Created At', ]; } /** * Gets query for [[Event]]. * * @return \yii\db\ActiveQuery */ public function getEvent() { return $this->hasOne(Event::class, ['id' => 'event_id']); } /** * Gets query for [[UserUsername]]. * * @return \yii\db\ActiveQuery */ public function getUserUsername() { return $this->hasOne(User::class, ['username' => 'user_username']); } }