MCQs Of Day 14 Laravel Relationships
MCQs Of Day 14 Laravel Relationships 1. Which of the following methods is used to define a one-to-many relationship in Laravel? a) hasOne() b) hasMany() c) belongsToMany() d) belongsTo() Answer: b) hasMany() Explanation: The hasMany() method is used to define a one-to-many relationship where a model can have many related records. 2. In a one-to-many relationship, which method is used in the child model to define the inverse relationship? a) hasMany() b) belongsTo() c) belongsToMany() d) hasOne() Answer: b) belongsTo() Explanation: In a one-to-many relationship, the child model uses the belongsTo() method to define the inverse relationship. 3. Which of the following statements is true about the belongsToMany() relationship? a) It is used for one-to-one relationships. b) It is used for one-to-many relationships. c) It is used for many-to-many relationships. d) It is used for polymorphic relationships. Answer: c) It is used for many-to-many relati...