12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?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 create($request)
- {
- if ($request['rule'] && is_array($request['rule'])){
- $rules = json_decode($request['rule'],true);
- if (count($rules)>10) {
- throw new HttpException(500, '最多只能添加10个banner海报');
- }
- }else{
- throw new HttpException(500, '参数有误');
- }
- $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, '添加失败');
- }
- }
- }
|