![]() |
Using beforeDelete in Model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Using beforeDelete in Model (/showthread.php?tid=76667) |
Using beforeDelete in Model - dusan - 06-08-2020 Hi, Let's say I have a table called 'projects'. One of the columns contains a filename string. What i'd like to do, is to delete the file after/before deleting the row from the database. I see, that Codeigniter 4's models can now use a callback function. But i don't know how can I access data, particularly the filename field. Code: <?php namespace App\Models; Or am I approaching this the wrong way? Should I just get the data in my Controller, delete the file and then delete the row from database? I would do that in CI3 this way, but now i discovered the callbacks in CI4 and I consider this a more elegant way/better practice. Thanks. |