You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An Eloquent model and Query builder with support for MongoDB, inspired by LMongo, but using the original Laravel methods. *This library extends the original Laravel classes, so it uses exactly the same methods.*
7
7
@@ -136,6 +136,11 @@ If you want to use Laravel's native Auth functionality, register this included s
136
136
137
137
This service provider will slightly modify the internal DatabaseReminderRepository to add support for MongoDB based password reminders. If you don't use password reminders, you don't have to register this service provider and everything else should work just fine.
138
138
139
+
Sentry
140
+
------
141
+
142
+
If yo want to use this library with [Sentry](https://cartalyst.com/manual/sentry), then check out https://github.com/jenssegers/Laravel-MongoDB-Sentry
143
+
139
144
Sessions
140
145
--------
141
146
@@ -423,6 +428,33 @@ Again, you may override the conventional local key by passing a second argument
423
428
424
429
return $this->embedsMany('Book', 'local_key');
425
430
431
+
### EmbedsOne Relations
432
+
433
+
There is also an EmbedsOne relation, which works similar to the EmbedsMany relation, but only stores one embedded model.
434
+
435
+
use Jenssegers\Mongodb\Model as Eloquent;
436
+
437
+
class Book extends Eloquent {
438
+
439
+
public function author()
440
+
{
441
+
return $this->embedsOne('Author');
442
+
}
443
+
444
+
}
445
+
446
+
Now we can access the book's author through the dynamic property:
447
+
448
+
$author = Book::first()->author;
449
+
450
+
Inserting and updating embedded documents works just like the `embedsMany` relation:
451
+
452
+
$author = new Author(array('name' => 'John Doe'));
453
+
454
+
$book = Books::first();
455
+
456
+
$author = $user->author()->save($author);
457
+
426
458
### MySQL Relations
427
459
428
460
If you're using a hybrid MongoDB and SQL setup, you're in luck! The model will automatically return a MongoDB- or SQL-relation based on the type of the related model. Of course, if you want this functionality to work both ways, your SQL-models will need to extend `Jenssegers\Eloquent\Model`. Note that this functionality only works for hasOne, hasMany and belongsTo relations.
0 commit comments