本文整理匯總了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;
}