Skip to content

Commit f7ec772

Browse files
author
Chris Cho
committed
rst fixes
1 parent cca3c56 commit f7ec772

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

docs/eloquent-models/relationships.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ many relationship with and a ``SpaceExplorer`` model.
264264
The ``SpaceExplorer`` model defines a ``BelongsToMany`` many to many
265265
relationship with ``Planet`` as shown in the following example class:
266266

267-
.. literalinclude:: /includes/eloquent-models/relationships/SpaceShipManyToMany.php
267+
.. literalinclude:: /includes/eloquent-models/relationships/SpaceExplorerManyToMany.php
268268
:language: php
269269
:dedent:
270270

@@ -433,7 +433,7 @@ created by running the code:
433433
_id: ObjectId('65e207b9aa167d29a3048855')
434434
}
435435
]
436-
}
436+
}
437437

438438

439439
.. _laravel-relationship-cross-database
@@ -509,10 +509,10 @@ see sample MongoDB documents created by running the code:
509509
:language: none
510510
:visible: false
511511

512-
+------+----------+
513-
| id | name |
514-
+------+----------+
515-
| 1234 | Nostromo |
516-
+------+----------+
517-
512+
+------+----------+
513+
| id | name |
514+
+------+----------+
515+
| 1234 | Nostromo |
516+
+------+----------+
517+
518518

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use MongoDB\Laravel\Eloquent\Model;
6+
use MongoDB\Database\Relations\BelongsTo;
7+
8+
class Passenger extends Model
9+
{
10+
protected $connection = 'mongodb';
11+
12+
public function spaceship(): BelongsTo
13+
{
14+
return $this->BelongsTo(SpaceShip::class);
15+
}
16+
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Database\Eloquent\Relations\HasMany;
7+
use MongoDB\Laravel\Eloquent\HybridRelations;
8+
9+
class SpaceShip extends Model
10+
{
11+
protected $connection = 'mysql';
12+
13+
public $primaryKey = 'id';
14+
public function passengers(): HasMany
15+
{
16+
return $this->hasMany(Passenger::class);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)