Suppose we have many to one relationship between table A and table B. Now there are two possibilities to define this relation in Laravel.
-
while creating migration I use the "References" Keyword. and the run the migration
-
The other way is I use hasMany and belongsTo in model class corresponding to those tables.
Can some one help me in understanding what approach I should follow. Or we need to have both the approach in our codebase to create relationships. Can some one throw some light on it. I am kind of confused. I am new to Laravel and learning these intricacies. thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire