Procházet zdrojové kódy

新增限制条数

duqinya před 5 roky
rodič
revize
fc8a0150a0
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 4 0
      app/Repositories/StarNewsRepository.php

+ 4 - 0
app/Repositories/StarNewsRepository.php

@@ -48,6 +48,10 @@ class StarNewsRepository
             'sort' => $request['sort'] ?? 0,
             'status' => $request['status'] ?? 0,
         ];
+        $open_news = $this->starNews->where('status',1)->count();
+        if ($open_news >= 5 && $request['status'] == 1){
+            throw new HttpException(500, '最多开启5条新闻');
+        }
 
         if (!$this->starNews->create($data)) {
             throw new HttpException(500, '添加失败');