Fat models - skin controllers with File Uploading - 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: Fat models - skin controllers with File Uploading (/showthread.php?tid=574) |
Fat models - skin controllers with File Uploading - Lykos22 - 12-22-2014 Hi all, I'd like to ask a question if possible regarding the "fat models - skin controllers" best practices. I have inside my model a method that holds both file uploading and image manipulation. The code works ok, but the problem is I can't figure out how to get the upload error, if occured, back in the controller in order to pass it to the view and display it to the user, or the upload data if the uploading was done successfully. This is an example of the code in my model: PHP Code: class Foo_Model extends CI_Model The code inside the controller PHP Code: public function upload(){ Thanks in advance RE: Fat models - skin controllers with File Uploading - InsiteFX - 12-22-2014 do_upload should be in your controller not your model, models are for business logic like database access of records etc; RE: Fat models - skin controllers with File Uploading - no1youknowz - 12-22-2014 (12-22-2014, 04:37 AM)InsiteFX Wrote: do_upload should be in your controller not your model, models are for business logic like database access of records etc; I'm not going to comment on the above code, because I use ajax for my uploading. But I have 6+ different "uploads" within my application. Do all 6 controllers have the logic to handle the uploading? Of course not, this would be silly to maintain 6 different code functions. Instead, I have 1 main upload "library" which each controller interfaces with and returns the data when an upload is successful or not. Ultimately, it's up to you what you decide to do. I never saw the logic in having models hold anything except database logic. Especially when you want to move away from CI. RE: Fat models - skin controllers with File Uploading - Lykos22 - 12-23-2014 (12-22-2014, 04:37 AM)InsiteFX Wrote: models are for business logic like database access of records etc; True! But doesn't uploading and image manipulation belong to business logic too? or at least their configuration settings (mean the two $config arrays)? RE: Fat models - skin controllers with File Uploading - Avenirer - 12-23-2014 (12-23-2014, 01:15 AM)Lykos22 Wrote:not according to the definition accepted by CodeIgniter(12-22-2014, 04:37 AM)InsiteFX Wrote: models are for business logic like database access of records etc; |