Skip to content

PHPORM-140: Fix documentation for inverse embed relationships #2734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/eloquent-models.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Keep in mind guarding still works, but you may experience unexpected behavior.
Schema
------

The database driver also has (limited) schema builder support. You can
The database driver also has (limited) schema builder support. You can
conveniently manipulate collections and set indexes.

Basic Usage
Expand Down Expand Up @@ -351,7 +351,7 @@ relation definition.

.. code-block:: php

$book = Book::first();
$book = User::first()->books()->first();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, Book::first() sends a query to the books collection. Which is not expected for embeds.


$user = $book->user;

Expand Down Expand Up @@ -455,7 +455,7 @@ Inserting and updating embedded models works similar to the ``hasOne`` relation:
$book->author()
->create(['name' => 'John Doe']);

You can update the embedded model using the ``save`` method (available since
You can update the embedded model using the ``save`` method (available since
release 2.0.0):

.. code-block:: php
Expand All @@ -476,13 +476,13 @@ You can replace the embedded model with a new model like this:
Cross-Database Relationships
----------------------------

If you're using a hybrid MongoDB and SQL setup, you can define relationships
If you're using a hybrid MongoDB and SQL setup, you can define relationships
across them.

The model will automatically return a MongoDB-related or SQL-related relation
The model will automatically return a MongoDB-related or SQL-related relation
based on the type of the related model.

If you want this functionality to work both ways, your SQL-models will need
If you want this functionality to work both ways, your SQL-models will need
to use the ``MongoDB\Laravel\Eloquent\HybridRelations`` trait.

**This functionality only works for ``hasOne``, ``hasMany`` and ``belongsTo``.**
Expand Down