Stack.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\models\entity;
  3. use Yii;
  4. /**
  5. * This is the model class for table "tmc_stack".
  6. *
  7. * @property int $id
  8. * @property string $title
  9. * @property int $warehouse
  10. * @property int $number
  11. */
  12. class Stack extends \yii\db\ActiveRecord
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function tableName()
  18. {
  19. return 'tmc_stack';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['number', 'warehouse'], '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. 'warehouse' => 'ID warehouse',
  40. 'number' => 'Number of warehouse',
  41. ];
  42. }
  43. /**
  44. * @return Warehouse|null
  45. */
  46. public function getWarehouse()
  47. {
  48. return Warehouse::findOne($this->warehouse);
  49. }
  50. /**
  51. * Формирует заголовок "1.2.3" где 1 - компания, 2 - номер склада, 3 - номер стеллажа
  52. *
  53. * @return string
  54. */
  55. public function toFormTitle()
  56. {
  57. return $this->getWarehouse()->company . '.' . $this->getWarehouse()->number . '.' . $this->number;
  58. }
  59. }