Express.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace addons\StarChain\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_star_chain_express}}".
  6. *
  7. * @property int $id
  8. * @property int $express_id
  9. * @property string $name
  10. * @property string $code
  11. */
  12. class Express extends BaseModel
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function tableName()
  18. {
  19. return '{{%addons_star_chain_express}}';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['express_id'], 'integer'],
  28. [['name', 'code'], 'string', 'max' => 64],
  29. ];
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function attributeLabels()
  35. {
  36. return [
  37. 'id' => 'ID',
  38. 'express_id' => 'Express ID',
  39. 'name' => 'Name',
  40. 'code' => 'Code',
  41. ];
  42. }
  43. /**
  44. * @param string $code
  45. * @return static|null
  46. */
  47. public static function getExpressByCode(string $code)
  48. {
  49. return static::find()->where(['code' => $code])->one();
  50. }
  51. }