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


PHP Post::onlyTrashed方法代码示例

本文整理汇总了PHP中app\Post::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::onlyTrashed方法的具体用法?PHP Post::onlyTrashed怎么用?PHP Post::onlyTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Post的用法示例。


在下文中一共展示了Post::onlyTrashed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handlePostInformation

 /**
  * Manage post personal information (IPs)
  *
  * @return void
  */
 protected function handlePostInformation()
 {
     $this->comment("    Pruning posts data...");
     $postIpLife = (int) Settings::get('ephePostIpLife', 0);
     $postTrashedLife = (int) Settings::get('ephePostHardDelete', 0);
     if ($postIpLife) {
         $carbonLife = Carbon::now()->subDays($postIpLife);
         $affected = Post::withTrashed()->where('created_at', '<=', $carbonLife)->whereNotNull('author_ip')->update(['author_ip' => null]);
         $this->comment("      Pruned {$affected} author IP(s).");
     }
     if ($postTrashedLife) {
         $carbonLife = Carbon::now()->subDays($postTrashedLife);
         // Destroy old, trashed posts.
         $affected = Post::onlyTrashed()->where('deleted_at', '<=', $carbonLife)->forceDelete();
         $this->comment("      Pruned {$affected} trashed post(s).");
     }
 }
开发者ID:JEWSbreaking8chan,项目名称:infinity-next,代码行数:22,代码来源:Autoprune.php

示例2: handlePostInformation

 /**
  * Manage post personal information (IPs)
  *
  * @return void
  */
 protected function handlePostInformation()
 {
     $this->comment("    Pruning posts data...");
     $postIpLife = (int) Settings::get('ephePostIpLife', 0);
     $postTrashedLife = (int) Settings::get('ephePostHardDelete', 0);
     if ($postIpLife) {
         $carbonLife = Carbon::now()->subDays($postIpLife);
         $affected = Post::withTrashed()->where('created_at', '<=', $carbonLife)->whereNotNull('author_ip')->update(['author_ip' => null]);
         $this->comment("      Pruned {$affected} author IP(s).");
     }
     if ($postTrashedLife) {
         $carbonLife = Carbon::now()->subDays($postTrashedLife);
         // Find old posts.
         $forTrash = Post::onlyTrashed()->select('post_id', 'deleted_at')->where('deleted_at', '<=', $carbonLife);
         // Remove relationships.
         $forTrash->chunk(100, function ($posts) {
             foreach ($posts as $post) {
                 $post->attachmentLinks()->delete();
             }
         });
         // Destroy old, trashed posts.
         $affected = $forTrash->forceDelete();
         $this->comment("      Pruned {$affected} trashed post(s).");
     }
 }
开发者ID:LulzNews,项目名称:infinity-next,代码行数:30,代码来源:Autoprune.php

示例3: testSoftDelete

 public function testSoftDelete()
 {
     // test trashed()
     $post = Post::find(1);
     $post->delete();
     $this->assertTrue($post->trashed());
     // test withTrashed()
     Post::find(2)->delete();
     $post = Post::find(2);
     $this->assertNull($post);
     $post = Post::withTrashed()->find(2);
     $this->assertNotNull($post);
     // test onlyTrashed()
     $post = Post::find(3);
     $this->assertNotNull($post);
     $post = Post::onlyTrashed()->find(3);
     $this->assertNull($post);
     // test restore
     $post = Post::find(3);
     $post->delete();
     $post->restore();
     $post1 = Post::find(3);
     $this->assertNull($post1);
     $post = Post::onlyTrashed()->find(3);
     $post->restore();
     $post1 = Post::find(3);
     $this->assertNotNull($post1);
 }
开发者ID:richarddlu,项目名称:test_eloquent,代码行数:28,代码来源:EloquentTest.php

示例4: archive

 public function archive()
 {
     return Post::onlyTrashed()->get();
 }
开发者ID:bertog,项目名称:eengineering-web,代码行数:4,代码来源:PostsController.php

示例5: getDeletedPost

 /**
  * Display a listing of deleted post
  */
 public function getDeletedPost()
 {
     $post = Post::onlyTrashed()->get();
     return view('admin/post/deletedPost', array('user' => $this->username, 'nav_post' => '', 'nav_del_post' => '', 'posts' => $post));
 }
开发者ID:ndro,项目名称:New-GI-Website-Concept,代码行数:8,代码来源:PostController.php


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