AuthAssignment.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace backend\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%auth_assignment}}".
  6. *
  7. * @property string $item_name
  8. * @property string $user_id
  9. * @property integer $created_at
  10. *
  11. * @property AuthItem $itemName
  12. */
  13. class AuthAssignment extends \yii\db\ActiveRecord
  14. {
  15. /**
  16. * @inheritdoc
  17. */
  18. public static function tableName()
  19. {
  20. return '{{%auth_assignment}}';
  21. }
  22. /**
  23. * @inheritdoc
  24. */
  25. public function rules()
  26. {
  27. return [
  28. [['item_name', 'user_id'], 'required'],
  29. [['created_at'], 'integer'],
  30. [['item_name', 'user_id'], 'string', 'max' => 64],
  31. [['item_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['item_name' => 'name']],
  32. ];
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function attributeLabels()
  38. {
  39. return [
  40. 'item_name' => 'Item Name',
  41. 'user_id' => 'User ID',
  42. 'created_at' => 'Created At',
  43. ];
  44. }
  45. /**
  46. * @return \yii\db\ActiveQuery
  47. */
  48. public function getItemName()
  49. {
  50. return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
  51. }
  52. }