Back
belongsTo()
Sets up a belongsTo
association between this model and the specified one.
Use this association when this model contains a foreign key referencing another model.
// Specify that instances of this model belong to an author. (The table for this model should have a foreign key set on it, typically named `authorid`.) belongsTo("author"); // Same as above, but because we have broken away from the foreign key naming convention, we need to set `modelName` and `foreignKey`. belongsTo(name="bookWriter", modelName="author", foreignKey="authorId");
Copied!