Warehouse.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\models\entity;
  3. use Yii;
  4. /**
  5. * This is the model class for table "tmc_warehouse".
  6. *
  7. * @property int $id
  8. * @property string $title
  9. * @property int $company
  10. * @property int $number
  11. */
  12. class Warehouse extends \yii\db\ActiveRecord
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function tableName()
  18. {
  19. return 'tmc_warehouse';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['number', 'company'], 'integer'],
  28. [['title'], 'string', 'max' => 255],
  29. ];
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function attributeLabels()
  35. {
  36. return [
  37. 'id' => 'ID',
  38. 'title' => 'Title',
  39. 'company' => 'ID company',
  40. 'number' => 'Number of warehouse',
  41. ];
  42. }
  43. /**
  44. * @return Companies|null
  45. */
  46. public function getCompany()
  47. {
  48. return Companies::findOne($this->company);
  49. }
  50. /**
  51. * @return Stack[]
  52. */
  53. public function getStacks()
  54. {
  55. return Stack::findAll(['warehouse' => $this->id]);
  56. }
  57. }