Storage.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\models\entity;
  3. /**
  4. * This is the model class for table "tmc_storage".
  5. *
  6. * @property int $id
  7. * @property string $title
  8. * @property int $company
  9. * @property int $warehouse
  10. * @property int $stack
  11. * @property int $cell
  12. * @property int $tmc
  13. */
  14. class Storage extends \yii\db\ActiveRecord
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public static function tableName()
  20. {
  21. return 'tmc_storage';
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function rules()
  27. {
  28. return [
  29. [['company', 'warehouse', 'stack', 'cell', 'tmc'], 'integer'],
  30. [['title'], 'string', 'max' => 255],
  31. ];
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function attributeLabels()
  37. {
  38. return [
  39. 'id' => 'ID',
  40. 'title' => 'Title',
  41. 'company' => 'ID company',
  42. 'warehouse' => 'ID warehouse',
  43. 'stack' => 'ID stack',
  44. 'cell' => 'ID cell',
  45. 'tmc' => 'ID tmc',
  46. ];
  47. }
  48. public function toFormTitle()
  49. {
  50. return $this->company . '.' . $this->getWarehouse()->number . '.' . $this->getStack()->number . '.' . $this->cell;
  51. }
  52. public function getCompany()
  53. {
  54. return $this->hasOne(Companies::class, ['id' => 'company']);
  55. }
  56. public function getWarehouse()
  57. {
  58. return Warehouse::findOne($this->warehouse);
  59. }
  60. public function getStack()
  61. {
  62. return Stack::findOne($this->stack);
  63. }
  64. public function getCell()
  65. {
  66. return $this->hasOne(Cell::class, ['id' => 'cell']);
  67. }
  68. public function getTmc()
  69. {
  70. return $this->hasOne(Tmc::class, ['id' => 'tmc']);
  71. }
  72. }