本文整理汇总了PHP中app\Comment::whereIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::whereIn方法的具体用法?PHP Comment::whereIn怎么用?PHP Comment::whereIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::whereIn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multidelete
public function multidelete()
{
$id = Input::get('id');
$do = new Comment();
$list = $do->whereIn('id', $id)->delete();
if ($list) {
return Redirect::back()->withErrors(Null);
} else {
return Redirect::back()->withInput()->withErrors('comment delete fail!');
}
}
示例2: handle
/**
* Handle the event.
*
* @param SingleAdLoaded $event
* @return void
*/
public function handle(SingleAdLoaded $event)
{
$ad = $event->ad;
$ad->increment('views');
if ($user = Auth::user()) {
if ($user->id == $ad->author_id) {
$ad->comments()->where('answer_to', null)->update(['is_viewed' => true]);
} else {
$questions_ids = $ad->comments()->where('author_id', $user->id)->get()->map(function ($question) {
return $question->id;
});
Comment::whereIn('answer_to', $questions_ids)->update(['is_viewed' => true]);
}
}
}
示例3: delcomment
public function delcomment(Request $request)
{
$id = (array) $request->id;
$comments = Comment::whereIn('id', $id)->get(['article_id']);
if ($comments) {
$articleIds = $comments->fetch('article_id');
Comment::whereIn('id', $id)->delete();
foreach ($articleIds as $article_id) {
Article::withTrashed()->whereId($article_id)->decrement('comment_count');
}
return response()->json(200);
} else {
return response()->json(404);
}
return response()->json($articleIds);
}
示例4: getSubComments
public function getSubComments()
{
$ids = SubComment::where('comment_id_from', '=', $this->id)->orderBy('created_at', 'DESC')->lists('comment_id_sub');
return Comment::whereIn('id', $ids)->get();
}