123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace App\Repositories;
- use App\Models\CmsContentTemplateSet;
- use Symfony\Component\HttpKernel\Exception\HttpException;
- class CmsContentTemplateSetRepository {
- public function __construct(CmsContentTemplateSet $cmsContentTemplateSet) {
- $this->cmsContentTemplateSet = $cmsContentTemplateSet;
- }
- /**
- * banner配置
- */
- public function bannerSet($request)
- {
- $rules = json_decode($request['rule'],true);
- if (is_array($rules)){
- if (count($rules)>10) {
- throw new HttpException(500, '最多只能添加10个banner海报');
- }
- $subject = [
- 'tpl_id' => $request['tpl_id'],
- 'rule' => $request['rule'],
- 'area_type' => $request['area_type'],
- 'status' => $request['status'],
- ];
- if (!$this->cmsContentTemplateSet->create($subject)) {
- throw new HttpException(500, '添加失败');
- }
- }else{
- throw new HttpException(500, '参数格式有误');
- }
- }
- /**
- * 专题广告配置
- */
- public function advertisementSet($request)
- {
- $rules = json_decode($request['rule'],true);
- if (is_array($rules)){
- $subject = [
- 'tpl_id' => $request['tpl_id'],
- 'rule' => $request['rule'],
- 'area_type' => $request['area_type'],
- 'status' => $request['status'],
- ];
- if (!$this->cmsContentTemplateSet->create($subject)) {
- throw new HttpException(500, '添加失败');
- }
- }else{
- throw new HttpException(500, '参数格式有误');
- }
- }
- /**
- * 商品楼层配置
- */
- public function floorSet($request)
- {
- $rules = json_decode($request['rule'],true);
- if (is_array($rules)){
- $subject = [
- 'tpl_id' => $request['tpl_id'],
- 'rule' => $request['rule'],
- 'area_type' => $request['area_type'],
- 'status' => $request['status'],
- ];
- if (!$this->cmsContentTemplateSet->create($subject)) {
- throw new HttpException(500, '添加失败');
- }
- }else{
- throw new HttpException(500, '参数格式有误');
- }
- }
- /**
- * 分类专题配置
- */
- public function categorySet($request)
- {
- $rules = json_decode($request['rule'],true);
- if (is_array($rules)){
- $subject = [
- 'tpl_id' => $request['tpl_id'],
- 'rule' => $request['rule'],
- 'area_type' => $request['area_type'],
- 'status' => $request['status'],
- ];
- if (!$this->cmsContentTemplateSet->create($subject)) {
- throw new HttpException(500, '添加失败');
- }
- }else{
- throw new HttpException(500, '参数格式有误');
- }
- }
- }
|