123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\common\model\store\shipping;
- use app\common\model\BaseModel;
- use app\common\repositories\store\CityAreaRepository;
- class ShippingTemplateRegion extends BaseModel
- {
- /**
- * Author:Qinii
- * Date: 2020/5/6
- * Time: 14:20
- * @return string
- */
- public static function tablePk(): string
- {
- return 'shipping_template_region_id';
- }
- /**
- * Author:Qinii
- * Date: 2020/5/6
- * Time: 14:20
- * @return string
- */
- public static function tableName(): string
- {
- return 'shipping_template_region';
- }
- public function getCityIDsAttr($value, $data)
- {
- if (!$data['city_id']) return [];
- $city_id = explode('/', $data['city_id']);
- $data = app()->make(CityAreaRepository::class)->search([])->where('id', 'in', $city_id)->select();
- $result = [];
- foreach ($data as $v) {
- $result[] = array_map('intval', explode('/', trim($v['path'] . $v['id'], '/')));
- }
- return $result;
- }
- public function setCityIdAttr($value)
- {
- return '/'.( implode('/',$value)).'/';
- }
- }
|