Skip to content

Commit 65e9648

Browse files
author
Chris Cho
committed
add tip on schema
1 parent 6f2ea84 commit 65e9648

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/eloquent-models/relationships.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ Cross-Database Relationship Example
458458
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
459459

460460
The following example class creates a ``hasMany`` relationship between a
461-
``SpaceShip`` model stored in a MySQL database and a ``Passenger`` model
461+
``SpaceShip`` model stored in a relational database and a ``Passenger`` model
462462
stored in a MongoDB database:
463463

464464
.. literalinclude:: /includes/eloquent-models/relationships/SpaceShipCrossHasMany.php
@@ -472,6 +472,16 @@ The ``Passenger`` model defines a ``BelongsToMany`` relationship with
472472
:language: php
473473
:dedent:
474474

475+
.. tip::
476+
477+
Make sure that your primary key defined in your relational database table
478+
schema matches the one that your model uses. To learn more about Laravel
479+
primary keys and schema definitions, see the following pages in the Laravel
480+
documentation:
481+
482+
- `Primary Keys <https://laravel.com/docs/{+laravel-docs-version+}/eloquent#primary-keys>`__
483+
- `Database: Migrations <https://laravel.com/docs/{+laravel-docs-version+}/migrations>`__
484+
475485
The following sample code shows how to create a ``SpaceShip`` model in
476486
a MySQL database and related ``Passenger`` models in a MongoDB database and
477487
the data created by running the code. Click the :guilabel:`View Output` button

0 commit comments

Comments
 (0)