Config.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 客户设置
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\crm\model;
  8. use think\Db;
  9. use app\admin\model\Common;
  10. use think\Request;
  11. use think\Validate;
  12. class Config extends Common
  13. {
  14. /**
  15. * 为了数据库的整洁,同时又不影响Model和Controller的名称
  16. * 我们约定每个模块的数据表都加上相同的前缀,比如CRM模块用crm作为数据表前缀
  17. */
  18. protected $name = 'crm_config';
  19. protected $createTime = 'create_time';
  20. protected $updateTime = 'update_time';
  21. protected $autoWriteTimestamp = true;
  22. /**
  23. * 保存相关信息
  24. * @author Michael_xu
  25. * @param
  26. * @return
  27. */
  28. public function createData($param)
  29. {
  30. //验证
  31. $validate = validate($this->name);
  32. if (!$validate->check($param)) {
  33. $this->error = $validate->getError();
  34. return false;
  35. }
  36. if ($this->data($param)->allowField(true)->save()) {
  37. return true;
  38. } else {
  39. $this->error = '添加失败';
  40. return false;
  41. }
  42. }
  43. }