ReportCode.php 666 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class ReportCode extends Model
  9. {
  10. public function setField($filed,$vale){
  11. $arr= explode(",",$this->$filed);
  12. if(!in_array($vale,$arr)) $this->$filed == '' ? $this->$filed =$vale : $this->$filed .=",".$vale;
  13. }
  14. public function rmField($filed,$vale){
  15. $arr= explode(",",$this->$filed);
  16. if(in_array($vale,$arr)){
  17. $key = array_search($vale,$arr);
  18. unset($arr[$key]);
  19. }
  20. $this->$filed=implode(",",$arr);
  21. }
  22. public function __destruct(){
  23. $this->save();
  24. }
  25. }