Addres.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\form\components;
  12. use crmeb\form\BaseComponent;
  13. use crmeb\form\BuildInterface;
  14. /**
  15. * 选择地址
  16. * Class Addres
  17. * @package crmeb\form\components
  18. */
  19. class Addres extends BaseComponent implements BuildInterface
  20. {
  21. const NAME = 'addres';
  22. /**
  23. * @var string[]
  24. */
  25. protected $rule = [
  26. 'title' => '',
  27. 'field' => '',
  28. 'value' => '',
  29. 'info' => '',
  30. ];
  31. /**
  32. * Map constructor.
  33. * @param string $field
  34. * @param string $title
  35. * @param array $value
  36. */
  37. public function __construct(string $field, string $title, array $value = null)
  38. {
  39. $this->rule['field'] = $field;
  40. $this->rule['title'] = $title;
  41. $this->rule['value'] = empty($value) ? '' : $value;
  42. }
  43. /**
  44. * @param string $info
  45. * @return $this
  46. */
  47. public function info(string $info)
  48. {
  49. $this->rule['info'] = $info;
  50. return $this;
  51. }
  52. /**
  53. * @return array|string[]
  54. */
  55. public function toArray(): array
  56. {
  57. $this->rule['name'] = self::NAME;
  58. $this->before();
  59. return $this->rule;
  60. }
  61. }