本文整理汇总了PHP中app\Post::whereUser_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::whereUser_id方法的具体用法?PHP Post::whereUser_id怎么用?PHP Post::whereUser_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::whereUser_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: total_like_user
/**
* Total like of user
* @author Tran Van Moi
* @since 2015/05/21
* @param int $user_id
* @return int
*/
public static function total_like_user($user_id)
{
$posts = Post::whereUser_id($user_id)->get();
$arr_post = [];
foreach ($posts as $post) {
$arr_post[] = $post['id'];
}
return Like::whereIn('post_id', $arr_post)->count();
}
示例2: deleteDelete
/**
* delete comment
* @author Tran Van Moi
* @since 2015/05/20
* @return int
*/
public function deleteDelete()
{
$data = Input::all();
$rules = ['cmt_id' => 'required|exists:comments,id'];
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return 404;
} else {
$check_role_cmt = Comment::whereId($data['cmt_id'])->whereDelete_status(0)->first();
$check_role_post = Post::whereUser_id(Auth::user()->id)->whereId($check_role_cmt->post_id)->first();
if ($check_role_cmt->user_id == Auth::user()->id || $check_role_post) {
$check_role_cmt->delete_status = 1;
$check_role_cmt->save();
return 200;
} else {
return 404;
}
}
}