@@ -21,7 +21,7 @@ Overview
2121--------
2222
2323When you use a relational database, the Eloquent ORM stores models as rows
24- in tables that correspond to the model classes. When you use MongoDB, the
24+ in tables that correspond to the model classes. When you use MongoDB, the
2525{+odm-short+} stores models as documents in collections that correspond to the
2626model classes.
2727
@@ -74,21 +74,23 @@ One to One Example
7474~~~~~~~~~~~~~~~~~~
7575
7676The following example class shows how to define a ``HasOne`` one to one
77- relationship between a ``Planet`` and ``Orbit`` model.
77+ relationship between a ``Planet`` and ``Orbit`` model by using the
78+ ``hasOne()`` method:
7879
7980.. literalinclude:: /includes/eloquent-models/relationships/one-to-one/Planet.php
8081 :language: php
8182 :dedent:
8283
83- The following example class shows how to define the inverse relationship with
84- ``Orbit`` by using the ``belongsTo()`` method:
84+ The following example class shows how to define the inverse ``BelongsTo``
85+ relationship between ``Orbit`` and ``Planet`` by using the ``belongsTo()``
86+ method:
8587
8688.. literalinclude:: /includes/eloquent-models/relationships/one-to-one/Orbit.php
8789 :language: php
8890 :dedent:
8991
9092The following sample code shows how to instantiate a model for each class
91- and add the relationship between them. Click the :guilabel:`View Output `
93+ and add the relationship between them. Click the :guilabel:`VIEW OUTPUT `
9294button to see the data created by running the code:
9395
9496.. io-code-block::
@@ -157,22 +159,23 @@ One to Many Example
157159~~~~~~~~~~~~~~~~~~~
158160
159161The following example class shows how to define a ``HasMany`` one to many
160- relationship between a ``Planet`` parent model and ``Moon`` child model.
162+ relationship between a ``Planet`` parent model and ``Moon`` child model by
163+ using the ``hasMany()`` method:
161164
162165.. literalinclude:: /includes/eloquent-models/relationships/one-to-many/Planet.php
163166 :language: php
164167 :dedent:
165168
166- To define the inverse of the relationship on ``Moon``, add the dynamic
167- property and call the ``belongsTo() `` method on it, as shown in the following
168- example class :
169+ The following example class shows how to define the inverse ``BelongsTo``
170+ relationship between a ``Moon `` child model and the and the ``Planet`` parent
171+ model by using the ``belongsTo()`` method :
169172
170173.. literalinclude:: /includes/eloquent-models/relationships/one-to-many/Moon.php
171174 :language: php
172175 :dedent:
173176
174- The following sample code shows how ton instantiate a model for each class
175- and add the relationship between them. Click the :guilabel:`View Output `
177+ The following sample code shows how to instantiate a model for each class
178+ and add the relationship between them. Click the :guilabel:`VIEW OUTPUT `
176179button to see the data created by running the code:
177180
178181.. io-code-block::
@@ -228,8 +231,8 @@ Many to Many Relationship
228231-------------------------
229232
230233A many to many relationship consists of a relationship between two different
231- model types in which one type of model record can be related to multiple
232- records of the other type.
234+ model types in which, for each type of model, an instance of the model can
235+ be related to multiple instances of the other type.
233236
234237In {+odm-short+}, you can define a many to many relationship by adding the
235238``belongsToMany()`` method to both related classes.
@@ -255,22 +258,24 @@ relationship between model classes.
255258Many to Many Example
256259~~~~~~~~~~~~~~~~~~~~
257260
258- The following ``Planet`` class shows how to define a ``BelongsToMany`` many to
259- many relationship with and a ``SpaceExplorer`` model.
261+ The following example class shows how to define a ``BelongsToMany`` many to
262+ many relationship between a ``Planet`` and ``SpaceExporer`` model by using
263+ the ``belongsToMany()`` method:
260264
261265.. literalinclude:: /includes/eloquent-models/relationships/many-to-many/Planet.php
262266 :language: php
263267 :dedent:
264268
265- The ``SpaceExplorer`` model defines a ``BelongsToMany`` many to many
266- relationship with ``Planet`` as shown in the following example class:
269+ The following example class shows how to define the inverse ``BelongsToMany``
270+ many to many relationship between a ``SpaceExplorer`` and ``Planet`` model by
271+ using the ``belongsToMany()`` method:
267272
268273.. literalinclude:: /includes/eloquent-models/relationships/many-to-many/SpaceExplorer.php
269274 :language: php
270275 :dedent:
271276
272277The following sample code shows how to instantiate a model for each class
273- and add the relationship between them. Click the :guilabel:`View Output `
278+ and add the relationship between them. Click the :guilabel:`VIEW OUTPUT `
274279button to see the data created by running the code:
275280
276281.. io-code-block::
@@ -391,15 +396,15 @@ relationship between a ``SpaceShip`` and ``Cargo`` model:
391396 :dedent:
392397
393398The embedded model class omits the relationship definition as shown in the
394- following example class:
399+ following ``Cargo`` model class:
395400
396401.. literalinclude:: /includes/eloquent-models/relationships/embeds/Cargo.php
397402 :language: php
398403 :dedent:
399404
400405The following sample code shows how to create a ``SpaceShip`` model and
401406embed multiple ``Cargo`` models and the MongoDB document created by running the
402- code. Click the :guilabel:`View Output ` button to see the data created by
407+ code. Click the :guilabel:`VIEW OUTPUT ` button to see the data created by
403408running the code:
404409
405410.. io-code-block::
@@ -462,16 +467,17 @@ relationship.
462467Cross-Database Relationship Example
463468~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
464469
465- The following example class creates a ``hasMany `` relationship between a
466- ``SpaceShip`` model stored in a relational database and a ``Passenger`` model
467- stored in a MongoDB database:
470+ The following example class shows how to define a ``HasMany `` relationship
471+ between a ``SpaceShip`` model stored in a relational database and a
472+ ``Passenger`` model stored in a MongoDB database:
468473
469474.. literalinclude:: /includes/eloquent-models/relationships/cross-db/SpaceShip.php
470475 :language: php
471476 :dedent:
472477
473- The ``Passenger`` model defines a ``BelongsToMany`` relationship with
474- ``SpaceShip`` as shown in the following example class:
478+ The following example class shows how to define the inverse ``BelongsTo``
479+ relationship between a ``Passenger`` model and the and the ``Spaceship``
480+ model by using the ``belongsTo()`` method:
475481
476482.. literalinclude:: /includes/eloquent-models/relationships/cross-db/Passenger.php
477483 :language: php
@@ -489,7 +495,7 @@ The ``Passenger`` model defines a ``BelongsToMany`` relationship with
489495
490496The following sample code shows how to create a ``SpaceShip`` model in
491497a MySQL database and related ``Passenger`` models in a MongoDB database and
492- the data created by running the code. Click the :guilabel:`View Output ` button
498+ the data created by running the code. Click the :guilabel:`VIEW OUTPUT ` button
493499to see the data created by running the code:
494500
495501.. io-code-block::
0 commit comments