當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。