One table for uploads for multiple resources in CakePHP
- by Mef
Hi,
I have CakePHP app in which I'd like to attach gallery to multiple resources. Let's say I've got artists, each one has own gallery. I've got articles, every article has some images attached to it and so on. Now I set up tables like this:
Artists hasMany Artistimages, fields in artistimages table are: id, artist_id, filename, filetype, filesize etc.
Articles hasMany Articleimages, fields in articleimages table are: id, article_id, filename, filetype, filesize etc.
...but this is not how it should be, I think.
Is there possibility to have one table called for example uploads which will contain all images with foreign key pointing to resource its reffering to? How to tell CakePHP which image is coming from which resource?