本文整理汇总了PHP中app\Article::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::onlyTrashed方法的具体用法?PHP Article::onlyTrashed怎么用?PHP Article::onlyTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::onlyTrashed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restoreDeleted
public function restoreDeleted($id)
{
$article = Article::onlyTrashed()->find($id, ['id']);
if (empty($article)) {
return response()->json(404);
}
$this->articles->restoreTags($article);
$article->restore();
return response()->json(200);
}
示例2: onlyDeleted
public function onlyDeleted()
{
$articles = Article::onlyTrashed()->with('user')->latest('deleted_at')->paginate(10);
return $articles;
}
示例3: restoreOrDelete
public function restoreOrDelete(Request $request)
{
$id = $request->id;
$action = $request->action;
$article = Article::onlyTrashed()->find($id);
if (empty($article)) {
return response()->json(['status' => 404, 'msg' => '文章不存在']);
}
if (Gate::denies('owns', $article)) {
return response()->json(['status' => 403, 'msg' => '无权操作非自己的文章']);
}
if (!in_array($action, ['restore', 'forceDelete'])) {
return response()->json(['status' => 403, 'msg' => '非法操作']);
}
if ($action == 'restore') {
$article->restore();
$this->articles->restoreTags($article);
return response()->json(['status' => 200, 'msg' => '恢复成功']);
} else {
$article->likes()->delete();
Comment::where('article_id', $article->id)->delete();
Auth::user()->histories()->create(['type' => 'article', 'content' => '清除文章《<a href="javascript:;">' . $article->title . '</a>》']);
$article->forceDelete();
return response()->json(['status' => 200, 'msg' => '删除成功']);
}
}
示例4: recycle
public function recycle()
{
$articles = Article::onlyTrashed()->paginate(15);
return view('admin.articles.recycle', compact('articles'));
}
示例5: onlyDeleted
public function onlyDeleted()
{
$articles = Article::onlyTrashed()->with('user')->Orderby('deleted_at', 'DESC')->paginate(10);
return $articles;
}
示例6: forceDelete
public function forceDelete($id)
{
Article::onlyTrashed()->find($id)->forceDelete();
return redirect('admin/articles/trash');
}