EnterpriseSite.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\model\enterprise;
  13. use app\common\model\BaseModel;
  14. /**
  15. * 商家后台菜单模型
  16. * Class Menu
  17. * @package app\common\model\admin
  18. */
  19. class EnterpriseSite extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'enterprise_site';
  23. // 定义表主键
  24. protected $pk = 'id';
  25. protected $CTYPE = ['HONORS'=>1,'COOPERATE'=>2,'HOME_SEO'=>3,'PRODUCT_SEO'=>4,'CONTACT_SEO'=>5];
  26. public function getContentsAttr($data){
  27. return htmlspecialchars_decode($data);
  28. }
  29. /**
  30. * 获取官网配置
  31. * @param $ctype
  32. * @return \app\enterprise\model\EnterpriseSite|array|\think\Model|null
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public function getSetting($ctype){
  38. return $this->where('ctype',$ctype)->field('id,title,keywords,desc,contents,ctype')->find();
  39. }
  40. public function getSettingBacth(){
  41. return $this->where('ctype','>',2)->field('id,title,keywords,desc,contents,ctype')
  42. ->select()->each(function (&$item){
  43. if ($item['ctype'] == 3){
  44. $item['i'] = 1;
  45. $item['t'] = '首页SEO';
  46. }
  47. if ($item['ctype'] == 4){
  48. $item['i'] = 2;
  49. $item['t'] = '产品介绍SEO';
  50. }
  51. if ($item['ctype'] == 5){
  52. $item['i'] = 3;
  53. $item['t'] = '联系我们SEO';
  54. }
  55. });
  56. }
  57. }