Persons.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%persons}}".
  6. *
  7. * @property int $id
  8. * @property int|null $org_id
  9. * @property string|null $first_name
  10. * @property string|null $last_name
  11. * @property string|null $position
  12. * @property int|null $created_at
  13. * @property int|null $updated_at
  14. * @property int|null $deleted_at
  15. *
  16. * @property Organizations $org
  17. */
  18. class Persons extends \yii\db\ActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%persons}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['org_id', 'created_at', 'updated_at', 'deleted_at'], 'integer'],
  34. [['first_name', 'last_name', 'position'], 'string', 'max' => 191],
  35. [['org_id'], 'exist', 'skipOnError' => true, 'targetClass' => Organizations::className(), 'targetAttribute' => ['org_id' => 'id']],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'org_id' => 'Org ID',
  46. 'first_name' => 'First Name',
  47. 'last_name' => 'Last Name',
  48. 'position' => 'Position',
  49. 'created_at' => 'Created At',
  50. 'updated_at' => 'Updated At',
  51. 'deleted_at' => 'Deleted At',
  52. ];
  53. }
  54. /**
  55. * Gets query for [[Org]].
  56. *
  57. * @return \yii\db\ActiveQuery|OrganizationsQuery
  58. */
  59. public function getOrg()
  60. {
  61. return $this->hasOne(Organizations::class, ['id' => 'org_id'])->inverseOf('persons');
  62. }
  63. /**
  64. * {@inheritdoc}
  65. * @return PersonsQuery the active query used by this AR class.
  66. */
  67. public static function find()
  68. {
  69. return new PersonsQuery(get_called_class());
  70. }
  71. }