Organizations.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%organizations}}".
  6. *
  7. * @property int $id
  8. * @property string $name
  9. * @property string|null $short_name
  10. * @property int|null $vat
  11. * @property int|null $edrpou
  12. * @property string|null $address_1
  13. * @property string|null $address_2
  14. * @property string|null $address_3
  15. * @property string|null $comment
  16. * @property int|null $bank_id
  17. * @property int|null $person_id
  18. * @property int|null $created_at
  19. * @property int|null $updated_at
  20. * @property int|null $deleted_at
  21. *
  22. * @property Persons[] $persons
  23. */
  24. class Organizations extends \yii\db\ActiveRecord
  25. {
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return '{{%organizations}}';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['name'], 'required'],
  40. [['vat', 'edrpou', 'bank_id', 'person_id', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
  41. [['comment'], 'string'],
  42. [['name', 'short_name', 'address_1', 'address_2', 'address_3'], 'string', 'max' => 191],
  43. ];
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function attributeLabels()
  49. {
  50. return [
  51. 'id' => 'ID',
  52. 'name' => 'Name',
  53. 'short_name' => 'Short Name',
  54. 'vat' => 'Vat',
  55. 'edrpou' => 'Edrpou',
  56. 'address_1' => 'Address 1',
  57. 'address_2' => 'Address 2',
  58. 'address_3' => 'Address 3',
  59. 'comment' => 'Comment',
  60. 'bank_id' => 'Bank ID',
  61. 'person_id' => 'Person ID',
  62. 'created_at' => 'Created At',
  63. 'updated_at' => 'Updated At',
  64. 'deleted_at' => 'Deleted At',
  65. ];
  66. }
  67. /**
  68. * Gets query for [[Persons]].
  69. *
  70. * @return \yii\db\ActiveQuery|PersonsQuery
  71. */
  72. public function getPersons()
  73. {
  74. return $this->hasMany(Persons::className(), ['org_id' => 'id'])->inverseOf('org');
  75. }
  76. /**
  77. * {@inheritdoc}
  78. * @return OrganizationsQuery the active query used by this AR class.
  79. */
  80. public static function find()
  81. {
  82. return new OrganizationsQuery(get_called_class());
  83. }
  84. }