当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::onlyTrashed方法代码示例

本文整理汇总了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);
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:10,代码来源:ArticleController.php

示例2: onlyDeleted

 public function onlyDeleted()
 {
     $articles = Article::onlyTrashed()->with('user')->latest('deleted_at')->paginate(10);
     return $articles;
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:5,代码来源:ArticleRepository.php

示例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' => '删除成功']);
     }
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:26,代码来源:ArticleController.php

示例4: recycle

 public function recycle()
 {
     $articles = Article::onlyTrashed()->paginate(15);
     return view('admin.articles.recycle', compact('articles'));
 }
开发者ID:axhello,项目名称:laravel-blog-demo,代码行数:5,代码来源:ArticleController.php

示例5: onlyDeleted

 public function onlyDeleted()
 {
     $articles = Article::onlyTrashed()->with('user')->Orderby('deleted_at', 'DESC')->paginate(10);
     return $articles;
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:5,代码来源:ArticleRepository.php

示例6: forceDelete

 public function forceDelete($id)
 {
     Article::onlyTrashed()->find($id)->forceDelete();
     return redirect('admin/articles/trash');
 }
开发者ID:kpaxer,项目名称:laravel-blog,代码行数:5,代码来源:ArticlesController.php


注:本文中的app\Article::onlyTrashed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。