本文整理匯總了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).");
}
}
示例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).");
}
}
示例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);
}
示例4: archive
public function archive()
{
return Post::onlyTrashed()->get();
}
示例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));
}