// +---------------------------------------------------------------------- declare (strict_types=1); namespace app\common\model\enterprise; use app\common\model\BaseModel; /** * 商家后台菜单模型 * Class Menu * @package app\common\model\admin */ class EnterpriseSite extends BaseModel { // 定义表名 protected $name = 'enterprise_site'; // 定义表主键 protected $pk = 'id'; protected $CTYPE = ['HONORS'=>1,'COOPERATE'=>2,'HOME_SEO'=>3,'PRODUCT_SEO'=>4,'CONTACT_SEO'=>5]; public function getContentsAttr($data){ return htmlspecialchars_decode($data); } /** * 获取官网配置 * @param $ctype * @return \app\enterprise\model\EnterpriseSite|array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getSetting($ctype){ return $this->where('ctype',$ctype)->field('id,title,keywords,desc,contents,ctype')->find(); } public function getSettingBacth(){ return $this->where('ctype','>',2)->field('id,title,keywords,desc,contents,ctype') ->select()->each(function (&$item){ if ($item['ctype'] == 3){ $item['i'] = 1; $item['t'] = '首页SEO'; } if ($item['ctype'] == 4){ $item['i'] = 2; $item['t'] = '产品介绍SEO'; } if ($item['ctype'] == 5){ $item['i'] = 3; $item['t'] = '联系我们SEO'; } }); } }