I have 3 tables, Cars, Flats and Shops. Each table has its photos. Photos is stored in database. I want to use only one table for photos, I don't want to create Photos table for each Cars, Flats and Shops.
Photos tables structe is like this;
| id | photo_url | type | destination_id |
------------------------------------------------------------
1 | http://example.com/1.jpg | Cars | 1 |
2 | http://example.com/2.jpg | Flats | 1 |
3 | http://example.com/3.jpg | Flats | 2 |
4 | http://example.com/4.jpg | Shops | 1 |
5 | http://example.com/3.jpg | Shops | 2 |
I need to define hasMany relationship with type in Shops, Flats and Cars model classes.
What is the correct way to do this?