本文整理汇总了PHP中app\Comment::getCommentInfoById方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::getCommentInfoById方法的具体用法?PHP Comment::getCommentInfoById怎么用?PHP Comment::getCommentInfoById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::getCommentInfoById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: commentToClassX
public function commentToClassX(Request $request)
{
onlyAllowPostRequest($request);
$all = $request->only(['post_id', 'author_id', 'content']);
$comment = Comment::create(['post' => intval($all['post_id']), 'author' => intval($all['author_id']), 'content' => $all['content']]);
$c = Comment::getCommentInfoById($comment->id);
return response()->json($c);
}
示例2: getCommentsByPostId
/**
* Get list comment by post_id
*
* @param $post_id
*
* @return null
*/
public static function getCommentsByPostId($post_id)
{
$comments = Comment::all()->where('post', intval($post_id));
if ($comments->count() == 0) {
return [];
}
$listComments = [];
foreach ($comments as $comment) {
$listComments[] = Comment::getCommentInfoById($comment->id);
}
return $listComments;
}
示例3: comment
public function comment(Request $request)
{
onlyAllowPostRequest($request);
$all = $request->only(['post', 'author', 'content']);
$comment = Comment::create(['post' => intval($all['post']), 'author' => intval($all['author']), 'content' => $all['content']]);
$c = Comment::getCommentInfoById($comment->id);
/**
* Dữ liệu trả về
*/
$response = new stdClass();
$response->error = false;
$response->comment = $c;
return response()->json($response);
}