deleted_at not getting set - 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: deleted_at not getting set (/showthread.php?tid=81317) |
deleted_at not getting set - rwilson12 - 02-15-2022 Hello, I have codeigniter 4.18 installed and my model has the following settings the database is postgresql 12 the fields in the database are timestamp without time zone data type protected $table = 'news'; protected $primaryKey = 'id'; protected $useAutoIncrement = true; protected $returnType = 'App\Entities\News\Article'; protected $useSoftDeletes = true; protected $allowedFields = ['title', 'body','me_uid','record_status']; protected $useTimestamps = true; protected $dateFormat = 'datetime'; protected $createdField = 'created_at'; protected $updatedField = 'updated_at'; protected $deletedField = 'deleted_at'; protected $validationRules = []; protected $validationMessages = []; protected $skipValidation = false; protected $record_status = 1; I have the following method deleting a record in the model $id = $record->id; $this->delete($id); according to the documentation the above code should update the deleted_at field with a timestamp and that is not happening If I save / update a record the updated_at field gets set with the updated timestamp so that is working properly when a record is saved the created_at field is getting set correctly any advice or solution would be greatly appreciated RE: deleted_at not getting set - iRedds - 02-15-2022 When using soft delete, the delete method works like an update. And if the update works, then a soft delete will work. There are two reasons why it won't work. 1. $id is empty; 2. $id is not in the database. RE: deleted_at not getting set - rwilson12 - 02-16-2022 Thank you for the update I got it to work I had a method named delete in the model class which was overriding the default delete method available in the model I renamed the method to deleteRecord which then called the default delete method in the model and now deleted_at is getting set |