This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I'm building a classified ads system and what I need is to specify different attributes for some of the categories. Lets say, cars, real estates etc. Every ad will have
- id
- name
- desc ...
and I was thing should I make another table for lets say car category
- ad_id
- body
- paint
- registration etc.
Whats the best solutions and how to build it ?
That makes sense, putting the common attributes on one table and then the specific attributes on another table.
So the Ad table has a type and then you can use a morphed relationship to the specific table.
class Ad extends Model
{
public $morphTo = [
'detailable' => []
];
}
Read more about polymorphic relationships in the docs: https://octobercms.com/docs/database/relations#one-to-one-polymorphic-relations
1-2 of 2