SubmitEditModel.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. class SubmitEditModel extends Model
  5. {
  6. // 表名
  7. protected $name = 'submit_edit';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. ];
  17. public function getImagesAttr($value)
  18. {
  19. if (empty($value)){
  20. return '';
  21. }
  22. $images=explode(',',trim($value));
  23. if (!empty($images)){
  24. foreach ($images as $k=>$v){
  25. $images[$k]=config('site.cdnurl').$v;
  26. }
  27. }
  28. // $status = [-1=>'删除',0=>'禁用',1=>'正常',2=>'待审核'];
  29. return $images;
  30. }
  31. public function getCreateTimeAttr($value)
  32. {
  33. return date('Y-m-d',$value);
  34. }
  35. public function property(){
  36. return $this->belongsTo('app\admin\model\Property','property_id','id')->field('id,p_name as name');
  37. }
  38. public function village(){
  39. return $this->belongsTo('app\admin\model\village\Village','village_id','id')->field('id,v_name as name');
  40. }
  41. public function dong(){
  42. return $this->belongsTo('app\admin\model\village\VillageDong','dong_id','id')->field('id,d_name as name');
  43. }
  44. public function danyuan(){
  45. return $this->belongsTo('app\admin\model\village\VillageDanyuan','danyuan_id','id')->field('id,dy_name as name');
  46. }
  47. public function hu(){
  48. return $this->belongsTo('app\admin\model\village\VillageHu','hu_id','id')->field('id,hu_name as name');
  49. }
  50. public function member(){
  51. return $this->belongsTo('app\admin\model\Member','mid','id')->field('id,avatar,nickname');
  52. }
  53. public function SubmitType(){
  54. return $this->belongsTo('app\admin\model\submit\SubmitTypeModel','type_id','id')->field('id,name');
  55. }
  56. }