|
|
|
@ -51,7 +51,7 @@ class Posts extends BaseController |
|
|
|
where peu.posts_id = p.id and peu.user_id = p.user_id and peu.type = 2 |
|
|
|
))"; |
|
|
|
|
|
|
|
$field = 'p.id,p.content,p.location,p.type,p.user_id,p.create_time'; |
|
|
|
$field = 'p.id,p.content,p.location,p.address as location_address,p.type,p.user_id,p.create_time'; |
|
|
|
$order = 'p.create_time desc'; |
|
|
|
$model = new PostsModel(); |
|
|
|
$list = $this->paginate($model->alias('p')->where($where)->whereOr($whereOr)->field($field)->order($order)); |
|
|
|
@ -72,15 +72,6 @@ class Posts extends BaseController |
|
|
|
'nickname' => $friendNickname |
|
|
|
]; |
|
|
|
|
|
|
|
$item['location_address'] = ''; |
|
|
|
if ($item['location']) { |
|
|
|
$ipArr = \Ip::find($item['location']); |
|
|
|
if (is_array($ipArr)) { |
|
|
|
$ipArr = array_unique($ipArr); |
|
|
|
} |
|
|
|
$item['location_address'] = trim(implode(" ", $ipArr)); |
|
|
|
} |
|
|
|
|
|
|
|
$item['files'] = PostsFile::getPostsFile($item['id']); |
|
|
|
|
|
|
|
$userIdArr = $friendIds; |
|
|
|
@ -105,7 +96,7 @@ class Posts extends BaseController |
|
|
|
['delete_time', '=', 0] |
|
|
|
]; |
|
|
|
|
|
|
|
$field = 'id,content,location,type,user_id,create_time'; |
|
|
|
$field = 'id,content,location,address,type,user_id,create_time'; |
|
|
|
$order = 'create_time desc'; |
|
|
|
$model = new PostsModel(); |
|
|
|
|
|
|
|
@ -134,7 +125,7 @@ class Posts extends BaseController |
|
|
|
'user_id' => $this->uid, |
|
|
|
'delete_time' => 0 |
|
|
|
]; |
|
|
|
$field = 'id,content,location,type,user_id,create_time'; |
|
|
|
$field = 'id,content,location,address,type,user_id,create_time'; |
|
|
|
$data = (new PostsModel())->where($where)->field($field)->find(); |
|
|
|
if (!$data) { |
|
|
|
return warning(lang('system.error')); |
|
|
|
@ -185,6 +176,7 @@ class Posts extends BaseController |
|
|
|
$content = $this->request->param('content', ''); |
|
|
|
$privacy = $this->request->param('privacy', ''); |
|
|
|
$location = $this->request->param('location', ''); |
|
|
|
$address = $this->request->param('address', ''); |
|
|
|
$video_file = $this->request->param('video_file', ''); |
|
|
|
$imgArr = $this->request->param('img_arr', []); |
|
|
|
$posts_id = $this->request->param('posts_id', ''); |
|
|
|
@ -226,7 +218,8 @@ class Posts extends BaseController |
|
|
|
'type' => $type, |
|
|
|
'content' => $content, |
|
|
|
'privacy' => $privacy, |
|
|
|
'location' => $location ?? '' |
|
|
|
'location' => $location ?? '', |
|
|
|
'address' => $address ?? '' |
|
|
|
]; |
|
|
|
if ($posts_id) { |
|
|
|
$info['update_time'] = time(); |
|
|
|
@ -300,16 +293,9 @@ class Posts extends BaseController |
|
|
|
public function getLastPosts() |
|
|
|
{ |
|
|
|
$existsWhere = ['user_id' => $this->uid, 'privacy' => 0, 'delete_time' => 0]; |
|
|
|
$field = 'id as posts_id,content,type,location'; |
|
|
|
$field = 'id as posts_id,content,type,location,address as location_address'; |
|
|
|
$data = PostsModel::where($existsWhere)->field($field)->find()->toArray(); |
|
|
|
if ($data) { |
|
|
|
if ($data['location']) { |
|
|
|
$ipArr = \Ip::find($data['location']); |
|
|
|
if (is_array($ipArr)) { |
|
|
|
$ipArr = array_unique($ipArr); |
|
|
|
} |
|
|
|
$data['location_address'] = trim(implode(" ", $ipArr)); |
|
|
|
} |
|
|
|
$fileWhere = [ |
|
|
|
'posts_id' => $data['posts_id'], |
|
|
|
'delete_time' => 0 |
|
|
|
|