123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- namespace catchAdmin\yunying\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\system\model\SysDictData;
- class KeyPersonnel extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'key_personnel';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 姓名
- 'name',
- // 性别
- 'gender',
- // 证件类型
- 'card_type',
- // 证件号码
- 'card_number',
- // 地址
- 'address',
-
- // 监护人姓名
- 'guardians_name',
- // 监护人性别
- 'guardians_gender',
- // 监护人联系电话
- 'guardians_phone',
- // 监护人地址
- 'guardians_address',
- 'rfid_sn',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 列表
- */
- public function getList()
- {
- $res=$this->dataRange()
- ->catchSearch()
- ->append(['guardians_gender_text', 'gender_text','card_type_text'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- return $res;
- }
- //根据姓名搜索
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%' . $value . '%');
- }
- public function searchRfidSnAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%' . $value . '%');
- }
- public function getGuardiansGenderTextAttr($value){
- $guardians_gender = $this->getData('guardians_gender');
- return (new SysDictData())->getValueByCode('GENDER_OPTION', $guardians_gender) ?: '';
- }
- public function getGenderTextAttr($value){
- $gender = $this->getData('gender');
- return (new SysDictData())->getValueByCode('GENDER_OPTION', $gender) ?: '';
- }
- public function getCardTypeTextAttr($value){
- $card_type = $this->getData('card_type');
- return (new SysDictData())->getValueByCode('CARD_TYPE_OPTION', $card_type) ?: '';
- }
- public function getGenderAttr($value){
- return (string)$value;
- }
- public function getGuardiansGenderAttr($value){
- return (string)$value;
- }
- }
|