瀏覽代碼

create post with lat and lng

xielin 5 年之前
父節點
當前提交
a34e712e96
共有 2 個文件被更改,包括 4 次插入0 次删除
  1. 2 0
      app/Http/Controllers/V1/PostController.php
  2. 2 0
      app/Repositories/PostRepositories.php

+ 2 - 0
app/Http/Controllers/V1/PostController.php

@@ -59,6 +59,8 @@ class PostController extends Controller
             'title' => 'nullable|string|max:20',
             'content' => 'required|string|max:1000',
             'location' => 'nullable|string|max:32',
+            'lat' => 'nullable|numeric',
+            'lng' => 'nullable|numeric',
             'imgs' => 'required_if:type,image|string',
         ]);
         if ($validator->fails()) {

+ 2 - 0
app/Repositories/PostRepositories.php

@@ -161,6 +161,8 @@ class PostRepositories
             'topic_ids' => implode(',', $topicIds),
             'title' => isset($request['title']) ? strip_tags($request['title']) : '',
             'content' => $request['content'],
+            'lat' => isset($request['lat']) ? number_format($request['lat'],8) : 0,
+            'lng' => isset($request['lng']) ? number_format($request['lng'],8) : 0,
             'location' => isset($request['location']) ? strip_tags($request['location']) : '',
             'is_suggest' => 0,
             'is_hide' => 0,