本文整理汇总了PHP中Post::getPostById方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getPostById方法的具体用法?PHP Post::getPostById怎么用?PHP Post::getPostById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::getPostById方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPost
public function getPost()
{
if ($_REQUEST['action'] == 'new') {
return View::make('post.new');
}
if ($_REQUEST['action'] == 'edit') {
$post = Post::getPostById($_REQUEST['post_id']);
$tags = Post::getTagsByPostId($_REQUEST['post_id']);
$tags = array_pluck($tags, 'tag_name');
return View::make('post.edit', array('post' => $post, 'tags' => $tags));
}
}
示例2: updatePost
public static function updatePost(array $post)
{
$postId = $post['postId'];
$headline = $post['headline'];
$body = $post['body'];
$updated = Post::updatePost(new Post($postId, $headline, $body, null, null, null));
if (is_a($updated, 'ErrorObject')) {
return $updated;
}
$postData = Post::getPostById($postId);
return $postData;
}
示例3: getCommentsOfPost
public static function getCommentsOfPost($post_id)
{
$comments = Comment::where('post_id', $post_id)->get();
foreach ($comments as $comment) {
$user_id = $comment['user_id'];
$user = User::getUserById($user_id);
$comment['username'] = $user['username'];
$comment['avatar_link'] = $user['avatar_link'];
$comment['email'] = $user['email'];
$post = Post::getPostById($comment["post_id"]);
$comment['title'] = $post['title'];
$format = "F j, Y, g:i a";
$date = new DateTime($post['updated_at']);
$formatDate = $date->format($format);
$comment['update_time'] = $formatDate;
}
return $comments;
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($post_id)
{
//
try {
if (Auth::check()) {
}
} catch (Exception $ex) {
return Response::json(array("message" => "Đăng nhập để comment", "isHide" => true), 404);
}
$content = Input::get('content');
$id = Auth::id();
if ($id == null) {
return Response::json(array("message" => "Đăng nhập để comment", "isHide" => true), 404);
}
if ($content != null) {
$comment = new Comment();
$comment->content = $content;
$comment->user_id = Auth::id();
$comment->post_id = $post_id;
$comment->avatar_link = Auth::user()->avatar_link;
$comment->save();
$user_id = $comment['user_id'];
$user = User::getUserById($user_id);
$comment['username'] = $user['username'];
$comment['email'] = $user['email'];
$post = Post::getPostById($comment["post_id"]);
$comment['title'] = $post['title'];
$format = "F j, Y, g:i a";
$date = new DateTime($post['updated_at']);
$formatDate = $date->format($format);
$comment['update_time'] = $formatDate;
if (isset($user['fb_img'])) {
$comment['fb_img'] = $user['fb_img'];
}
if ($comment["user_id"] == $id) {
$comment["owner"] = true;
} else {
$comment["owner"] = false;
}
return Response::json($comment);
} else {
return Response::json(array('success' => false));
}
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//Auth::check()
// if(true) {
$content = Input::get('content');
$id = Auth::id();
if ($content != null) {
$comment = new Comment();
$comment->content = $content;
$comment->user_id = Auth::id();
$comment->save();
$user_id = $comment['user_id'];
$user = User::getUserById($user_id);
$comment['username'] = $user['username'];
$comment['email'] = $user['email'];
$post = Post::getPostById($comment["post_id"]);
$comment['title'] = $post['title'];
$format = "F j, Y, g:i a";
$date = new DateTime($post['updated_at']);
$formatDate = $date->format($format);
$comment['update_time'] = $formatDate;
if (isset($user['fb_img'])) {
$comment['fb_img'] = $user['fb_img'];
}
if ($comment["user_id"] == $id) {
$comment["owner"] = true;
} else {
$comment["owner"] = false;
}
return Response::json($comment);
} else {
return Response::json(array('success' => false));
}
// else
// {
// return Redirect::to('/login');
// }
}
示例6: isset
<?php
require_once '../classes/domains/Categories.php';
require_once '../classes/domains/Post.php';
$postId = isset($_GET["pid"]) ? $_GET['pid'] : null;
if (!is_null($postId)) {
$postArray = Post::getPostById($postId);
$post = $postArray[0];
} else {
$post = new Post(0, '', '');
//redirect back to where they came from.
}
$currentCategory = Categories::getCategoryById($post->categoryId);
$currentActiveString = $currentCategory[0]->category;
$showBottomLink = false;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
require_once 'views/header.php';
?>
<link href="../assets/css/styles/tomorrow-night-eighties.css" rel="stylesheet">
<style>
fieldset.fieldset-override {
padding: 20px 20px 20px 20px;
background-color: #FFFFFF;
border: 1px solid #DDDDDD;
border-radius: 4px 4px 4px 4px;
margin: 15px 0;
示例7:
<?php
require_once 'includes/config.inc.php';
if (isset($_GET['id']) && intval($_GET['id']) > 0) {
$id = $_GET['id'];
$post = Post::getPostById($id);
} else {
redirect_to('.');
}
require_once VIEW_PATH . 'read.view.php';
示例8: function
});
$app->post('/uploadCover', function () use($user, $app, $login) {
echo json_encode($user->uploadCover($_SESSION['auth']['user_id'], $_FILES['cover'], $login));
});
$app->put('/changePassword', function () use($user, $app) {
$passwords = json_decode($app->request->getBody(), true);
echo json_encode($user->changePassword($_SESSION['auth']['user_id'], $passwords));
});
/**
* Posts
*/
$app->get('/posts/:type/:user_id/:offset/:limit', function ($type, $user_id, $offset, $limit) use($post, $app) {
echo json_encode($post->getPosts($type, $user_id, null, $offset, $limit));
});
$app->get('/post/:id', function ($id) use($post) {
echo json_encode($post->getPostById($id));
});
$app->post('/post', function () use($post, $app) {
$data = json_decode($app->request->getBody());
echo json_encode($post->publishPost($_SESSION['auth']['user_id'], $data->friend_id, $data->content));
});
$app->delete('/post', function () use($post, $app) {
$post_id = json_decode($app->request->getBody());
echo json_encode($post->deletePost($_SESSION['auth']['user_id'], $post_id));
});
/**
* Posts - Like
*/
$app->put('/post/like', function () use($post, $app) {
$post_id = json_decode($app->request->getBody());
echo json_encode($post->likePost($_SESSION['auth']['user_id'], $post_id));
示例9: getUpdate
public function getUpdate($id)
{
$post = Post::getPostById($id);
return View::make('post.update', array('post' => $post));
}