Move file deletion code from controller into model