本文整理汇总了PHP中app\Posts::getLatlng方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::getLatlng方法的具体用法?PHP Posts::getLatlng怎么用?PHP Posts::getLatlng使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Posts
的用法示例。
在下文中一共展示了Posts::getLatlng方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPost
public static function addPost($input)
{
$validation = Validator::make($input, Posts::$addPostRules);
if ($validation->fails()) {
return Response::json(array('status' => '0', 'msg' => $validation->getMessageBag()->first()), 200);
} else {
$access_token = $input['token'];
$title = $input['title'];
$skillset = $input['skillset'];
$place_id = $input['place_id'];
$min_age = $input['min_age'];
$max_age = $input['max_age'];
$post_desc = isset($input['post_desc']) ? $input['post_desc'] : "";
$post_image = Input::file('post_image');
$post_video = Input::file('post_video');
$current_time = new DateTime();
if (is_string($skillset)) {
$skillset = str_replace('"', "", $skillset);
$skillset = explode(",", $skillset);
} else {
$skillset = json_decode($skillset, true);
}
$user_id = Users::getUserIdByToken($access_token);
if ($user_id) {
$place_data = Posts::getLatlng($place_id);
$lat = $place_data['location']['lat'] ? $place_data['location']['lat'] : '0';
$lng = $place_data['location']['lng'] ? $place_data['location']['lng'] : '0';
//users with matching skillset
$user_data = DB::table('user_skillset')->selectRaw('users.apn_id,users.reg_id,users.push_notification')->Join('users', 'users.id', '=', 'user_skillset.user_id')->whereIN('user_skillset.skillset_id', $skillset)->groupBy('users.id')->get();
if ($post_image == "") {
$image = "";
} else {
$image = Users::uploadPostFiles('post_image');
}
$notify_message = "New Post matching your skillset";
if ($post_video == "") {
$video = "";
} else {
$video = Users::uploadPostFiles('post_video');
}
$post_id = DB::table('posts')->insertGetId(array('user_id' => $user_id, 'title' => $title, 'post_desc' => $post_desc, 'post_image' => $image, 'post_video' => $video, 'min_age' => $min_age, 'max_age' => $max_age, 'post_lat' => $lat, 'post_lng' => $lng, 'created_at' => $current_time));
if ($skillset) {
foreach ($skillset as $key => $value) {
$skill[$key] = DB::table('post_skillset')->select('*')->where('post_id', $post_id)->where('user_id', $user_id)->where('skillset_id', $value)->get();
if (!$skill[$key]) {
$post_skill = DB::table('post_skillset')->insertGetId(array('user_id' => $user_id, 'post_id' => $post_id, 'skillset_id' => $value, 'created_at' => $current_time));
}
}
}
$post_desc = Posts::PostDesc($user_id, $post_id);
foreach ($user_data as $row) {
if ($row->push_notification) {
Notifications::SendPushNotification($notify_message, '', $row->apn_id, 3, $post_id, $user_id);
Notifications::SendPushNotification($notify_message, $row->reg_id, '', 3, $post_desc, $user_id);
}
}
if ($post_id) {
return Response::json(array('status' => '1', 'msg' => 'New Post Added'), 200);
} else {
return Response::json(array('status' => '0', 'msg' => "Error"), 200);
}
} else {
return Response::json(array('status' => '0', 'msg' => "Token Expired"), 200);
}
}
}