Browse Source

富文本标题

wzq 5 years ago
parent
commit
aeb1f77d34

+ 1 - 1
app/Http/Controllers/Post/PostController.php

@@ -182,7 +182,7 @@ class PostController extends Controller
             'video' => 'required_if:type,video|string|url',
             'video_id' => 'required_if:type,video|string',
             'topic_ids' => 'required|string|max:64',
-            'title' => 'required_if:type,html|string|max:20',
+            'title' => 'nullable|string|max:20',
             'content' => 'required|string',
             'location' => 'nullable|string|max:20',
             'imgs' => 'required_if:type,image|array|max:9',

+ 7 - 1
app/Repositories/Post/PostRepository.php

@@ -65,7 +65,13 @@ class PostRepository
      */
     public function create($request)
     {
-
+        //富文本标题
+        if($request['type'] == 'html' && (!isset($request['title']) || !$request['title'])){
+            return Response::create([
+                'message' => '当类型是富文本时,标题不能为空',
+                'status_code' => 500
+            ]);
+        }
         //验证小号
         $userInfo = $this->getUserInfo($request['uid']);
         Log::debug('发布内容小号信息:' . json_encode($userInfo));