i have two models. Batch and Subject. The relation between them are Batch HAS_MANY Subjects. The problem is that three subject are MUST and for all batches. How can i implement this fixed values (the three subjects) in the model?
i have two models. Batch and Subject. The relation between them are Batch HAS_MANY
Share
If you really don’t want to store the 3 default subjects in the database, you could write a function that returns the default subjects combined with any subjects that are actually related to the Batch object.
Assuming your relation is called ‘subjects’:
The limitation is that you can’t reference the default subjects in database criteria, and you have to make sure to use
$model->allSubjectsinstead of$model->subjects