I'd like to create a many-to-many relationship between two things: Notes and Labels. However, I'd like to define the labels themselves in code rather than having them in a database table.
Aside from a notes
table to represent the Note model, I expect to have a "pivot" table (labels_notes
) with two columns: note_id
and label
.
So, my question is: How would eager loading, getter, setter and "get notes by label" methods on the Note model work?
Background: The primary reason for wanting the Labels in code rather than as content of a table is that they are a small, fixed set of values; users will not be allowed to modify them. Further, there may need to be special logic in the code around certain labels. I considered storing them in a JSON column on notes
, but am concerned about the performance impact when searching for Notes by Label.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HrCNFD
via IFTTT
Aucun commentaire:
Enregistrer un commentaire