SystemConfigTab.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @author: xaboy<365615158@qq.com>
  4. * @day: 2017/11/02
  5. */
  6. namespace app\admin\model\system;
  7. use crmeb\traits\ModelTrait;
  8. use crmeb\basic\BaseModel;
  9. use think\facade\Db;
  10. /**
  11. * 配置分类model
  12. * Class SystemConfigTab
  13. * @package app\admin\model\system
  14. */
  15. class SystemConfigTab extends BaseModel
  16. {
  17. /**
  18. * 数据表主键
  19. * @var string
  20. */
  21. protected $pk = 'id';
  22. /**
  23. * 模型名称
  24. * @var string
  25. */
  26. protected $name = 'system_config_tab';
  27. use ModelTrait;
  28. /**
  29. * 获取单选按钮或者多选按钮的显示值
  30. * @param $menu_name
  31. * @param $value
  32. * @return string
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. * @throws \think\exception\DbException
  36. */
  37. public static function getRadioOrCheckboxValueInfo($menu_name,$value){
  38. $parameter = array();
  39. $option = array();
  40. $config_one = SystemConfig::getOneConfig('menu_name',$menu_name);
  41. $parameter = explode("\n",$config_one['parameter']);
  42. foreach ($parameter as $k=>$v){
  43. if(isset($v) && strlen($v)>0){
  44. $data = explode('=>',$v);
  45. $option[$data[0]] = $data[1];
  46. }
  47. }
  48. $str = '';
  49. if(is_array($value)){
  50. foreach ($value as $v){
  51. $str .= $option[$v].',';
  52. }
  53. }else{
  54. $str .= !empty($value)?$option[$value]:$option[0];
  55. }
  56. return $str;
  57. }
  58. /**
  59. * 获取全部
  60. * @param int $type
  61. * @return \think\Collection
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\ModelNotFoundException
  64. * @throws \think\exception\DbException
  65. */
  66. public static function getAll($type = 0){
  67. $where['status'] = 1;
  68. if($type>-1)$where['type'] = $type;
  69. return Db::name('SystemConfigTab')->where($where)->select();
  70. }
  71. /**
  72. * 获取配置分类
  73. * @param array $where
  74. * @return array
  75. */
  76. public static function getSystemConfigTabPage($where = array())
  77. {
  78. $model = new self;
  79. if($where['title'] != '') $model = $model->where('title','LIKE',"%$where[title]%");
  80. if($where['status'] != '') $model = $model->where('status',$where['status']);
  81. return self::page($model,$where);
  82. }
  83. }