Floor.php
958 字节
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
<?php
namespace app\school\model\project_appointment;
use think\Db;
use think\Model;
use traits\model\SoftDelete;
class Floor extends Model
{
use SoftDelete;
// 数据表名称
protected $name = 'project_floor';
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
protected $append = [
'building_name'
];
public function getBuildingNameAttr($value,$data){
return isset($data['building_id']) ? Db::name('project_building')->where(['id' => $data['building_id']])->value('building_name') : '';
}
/**
* 根据楼宇ID 获取楼层
* @param $buildingId 楼宇ID
*/
public function getListByBuildingId($buildingId)
{
return $this->where(['building_id' => $buildingId])->select();
}
}