Address.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/5/13
* Time: 10:57
*/
namespace app\index\model;
use think\Model;
class Address extends Model
{
public function selectData($where){
$data = $this->where($where)->order('createtime desc')->select();
$areaModel = new Area();
foreach ($data as $key => $vo){
$province_name = $areaModel->where(['id'=>$vo['province_id']])->value('name');
$city_name = $areaModel->where(['id'=>$vo['city_id']])->value('name');
$county_name = $areaModel->where(['id'=>$vo['county_id']])->value('name');
$data[$key]['province_name'] = $province_name;
$data[$key]['city_name'] = $city_name;
$data[$key]['county_name'] = $county_name;
}
return $data;
}
public function findData($where){
$data = $this->where($where)->find();
$areaModel = new Area();
$province_name = $areaModel->where(['id'=>$data['province_id']])->value('name');
$city_name = $areaModel->where(['id'=>$data['city_id']])->value('name');
$county_name = $areaModel->where(['id'=>$data['county_id']])->value('name');
$data['province_name'] = $province_name;
$data['city_name'] = $city_name;
$data['county_name'] = $county_name;
return $data;
}
public function insertData($data){
$result = $this->insertGetId($data);
return $result;
}
public function updateData($where,$data){
$result = $this->where($where)->update($data);
return $result;
}
}