本文整理汇总了PHP中app\Posts::PostDesc方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::PostDesc方法的具体用法?PHP Posts::PostDesc怎么用?PHP Posts::PostDesc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Posts
的用法示例。
在下文中一共展示了Posts::PostDesc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: likePost
public static function likePost($input)
{
$validation = Validator::make($input, Posts::$likePostRules);
if ($validation->fails()) {
return Response::json(array('status' => '0', 'msg' => $validation->getMessageBag()->first()), 200);
} else {
$access_token = $input['token'];
$post_id = $input['post_id'];
$current_time = new DateTime();
$user_id = Users::getUserIdByToken($access_token);
if ($user_id) {
$uname = Users::getUsername($user_id);
$other_id = Posts::getPostOwner($post_id);
$push_status = Users::getPushSettings($other_id);
$user_det = Users::getUserType($user_id);
$user_type = $user_det->user_type;
$push_ids = Users::getUserPushIds($other_id);
$reg_id = $push_ids->reg_id;
$device_token = $push_ids->apn_id;
$post_data = DB::table('likes')->select('*')->where('post_id', $post_id)->where('user_id', $user_id)->first();
if (!$post_data) {
$like_id = DB::table('likes')->insertGetId(array('user_id' => $user_id, 'post_id' => $post_id, 'created_at' => $current_time));
if ($user_id != $other_id) {
$post_desc = Posts::PostDesc($other_id, $post_id);
$notify_message = $uname . " liked your post";
$Ninput['sender_id'] = $user_id;
$Ninput['receiver_id'] = Posts::getPostOwner($post_id);
$Ninput['type_id'] = $like_id;
$Ninput['type'] = 'like';
$Ninput['title'] = $notify_message;
Notifications::addNotification($Ninput);
if ($push_status) {
Notifications::SendPushNotification($notify_message, '', $device_token, 2, $post_id, $user_id);
Notifications::SendPushNotification($notify_message, $reg_id, '', 2, $post_desc, $user_type);
}
}
if ($like_id) {
return Response::json(array('status' => '1', 'msg' => 'Post Liked'), 200);
} else {
return Response::json(array('status' => '0', 'msg' => "Error"), 200);
}
} else {
return Response::json(array('status' => '2', 'msg' => 'Post Already liked by user'), 200);
}
} else {
return Response::json(array('status' => '0', 'msg' => "Token Expired"), 200);
}
}
}