CodeIgniter Forums
model->delete() with SoftDelete how to undelete? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: model->delete() with SoftDelete how to undelete? (/showthread.php?tid=88180)



model->delete() with SoftDelete how to undelete? - Project Linde37 - 08-03-2023

Reference : https://codeigniter4.github.io/userguide/models/model.html#delete
with $useSoftDeletes: true one can 'hide a row'.
Is there an option to undelete()?


RE: model->delete() with SoftDelete how to undelete? - kenjis - 08-03-2023

(08-03-2023, 09:06 PM)Project Linde37 Wrote: Is there an option to undelete()?

No.


RE: model->delete() with SoftDelete how to undelete? - ozornick - 08-04-2023

$builder->set('deleted_at', null)->update($id); ?


RE: model->delete() with SoftDelete how to undelete? - dgvirtual - 08-05-2023

You simply have to set the deleted_at field to null (deleted rows contain datetime string there).

So, running something like

model('YourModel')->update(3, ['deleted_at' => null]);

Would do the trick