i'm newbie in MVC (using codeIgniter as my example) and i have read MVC fat model and skinny controller for like 3 times, what i got :
- model does the hardwork while controller calls the model and passes the data to be rendered by view
but i have one confusion , example i have an admin page that would delete product data in the db, i would have this codes (using codeIgniter):
public function deleteProduct($id = '')
{
if( is_digit($id))
{
$this->load->model('productModel');
$this->productModel->deleteById($id);
//oops product has images in another DB table and in server, so i need to delete it
$success = $this->_deleteProductImages($id);
}
else
{
//redirect because of invalid param
}
//if success TRUE then load the view and display success
//else load the view and display error
}
protected function _deleteProductImages($productId)
{
$this->load->model('productModel');
//return array of images path
$imgs = $this->productModel->getImagesPath($productId);
// after i got the imgs data, then delete the image in DB that references to the $productId
$this->productModel->deleteImage($productId);
foreach($imgs as $imgPath)
{
if(file_exists $imgPath) unlink($imgPath);
}
}
my question is :
in the concept of thin controller and fat model, should i move the method _deleteProductImages($id)
to my productModel or should i leave it like that? if you have another better approach then please guide me here