本文整理匯總了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);
}
}
}