当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::getPostById方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:jacobross85,项目名称:community,代码行数:12,代码来源:AdminController.php

示例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;
 }
开发者ID:eggmatters,项目名称:eggmatters_com,代码行数:12,代码来源:PostController.php

示例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;
 }
开发者ID:Hungmaix94,项目名称:Medusa,代码行数:18,代码来源:Comment.php

示例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));
     }
 }
开发者ID:Hungmaix94,项目名称:Medusa,代码行数:49,代码来源:PostCommentController.php

示例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');
     //        }
 }
开发者ID:Hungmaix94,项目名称:Medusa,代码行数:43,代码来源:CommentController.php

示例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;
开发者ID:eggmatters,项目名称:eggmatters_com,代码行数:30,代码来源:post.php

示例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';
开发者ID:hxkclan,项目名称:webiq.assignment,代码行数:10,代码来源:read.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));
开发者ID:volanderon,项目名称:socialnetwork,代码行数:31,代码来源:index.php

示例9: getUpdate

 public function getUpdate($id)
 {
     $post = Post::getPostById($id);
     return View::make('post.update', array('post' => $post));
 }
开发者ID:Hungmaix94,项目名称:Medusa,代码行数:5,代码来源:PostController.php


注:本文中的Post::getPostById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。