簡體   English   中英

如何在Laravel中編輯軟刪除的數據而不將其還原?

[英]How to edit soft deleted data without restore it in Laravel?

我已使用SoftDeleteevents表中刪除events SoftDelete運行正常。 我已經在視圖中顯示了SoftDelete事件withTrashed()並顯示了它。 現在,我想編輯該SoftDelete事件數據而不恢復它。 可能嗎?

我收到錯誤400-嘗試過該頁面后找不到

$data['events'] = $qBuilder->EventComplete()->withTrashed()
                    ->orderBy('events.event_date', 'desc')
                    ->groupBy('events.id')
                    ->paginate(AppHelper::getConfigValue('ADMIN-PAGINATION-LIMIT'));

應該是這樣的:

Model::withTrashed()->find(5)->update(['attribute' => 'value']);

因此,您正在雄辯地使用withTrashed-查找單個模型(此處ID = 5),然后更新所需的屬性。

您沒有顯示更多,但是,在您情況下,如果您使用Route模型綁定 ,則可能需要對其進行調整以允許找到軟刪除的模型:

Route::bind('user', function ($value) {
    return App\User::withTrashed()->findOrFail($value);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM