本文整理汇总了PHP中app\Article::withTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::withTrashed方法的具体用法?PHP Article::withTrashed怎么用?PHP Article::withTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::withTrashed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
public function view($id)
{
$article = Article::withTrashed()->with('user')->findOrFail($id);
$comments = $article->comments()->with('user')->recent()->simplePaginate(10);
$article->increment('view_count');
return view('articles.view', compact('article', 'comments'));
}
示例2: 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);
}
示例3: allWithDelete
public function allWithDelete()
{
$articles = Article::withTrashed()->with('user')->latest()->paginate(10);
return $articles;
}
示例4: delete
public function delete($id)
{
$delete = Article::withTrashed()->where('id', $id)->forceDelete();
if ($delete) {
return redirect('admin/article/recycle')->with('message', '删除成功!');
} else {
return Redirect::back()->withInput()->withErrors('删除失败!');
}
}
示例5: allWithDelete
public function allWithDelete()
{
$articles = Article::withTrashed()->with('user')->Orderby('created_at', 'DESC')->paginate(10);
return $articles;
}